Table of Contents

Property CodeSnippets

Namespace
Alternet.Syntax
Assembly
Alternet.Syntax.v9.dll

CodeSnippets

When implemented by a class, returns code snippets for the given parser.

[Browsable(false)]
public virtual ICodeSnippetsProvider CodeSnippets { get; }

Property Value

ICodeSnippetsProvider

Examples

Here is how to use a CodeSnippets in the C# code:

using System.IO;
using System.Collections.Generic;

using Alternet.Syntax;
using Alternet.Editor;

public partial class Form1 : Form
{
    private string dir = Application.StartupPath + @"\";

    private void Form1_Load(object sender, EventArgs e)
    {
        var parser = new SyntaxParser();
        var edit = new SyntaxEdit();
        edit.Parent = this;
        edit.Lexer = parser;
        FileInfo fileInfo = new FileInfo(dir + @"\VB.xml");
        if (fileInfo.Exists)
            parser.CodeSnippets.LoadFile(fileInfo.FullName);

        string fileName = "myfile.cs";
        if (System.IO.File.Exists(fileName))
        {
            parser.FileName = fileName;
            edit.LoadFile(fileName);
        }
    }
}

Here is how to use a CodeSnippets in the Visual Basic code:

Imports System.IO
Imports System.Collections.Generic

Imports Alternet.Syntax
Imports Alternet.Editor

Partial Public Class Form1
    Inherits Form

    Private dir As String = Application.StartupPath & "\"

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim parser = New SyntaxParser()
        Dim edit = New SyntaxEdit()
        edit.Parent = Me
        edit.Lexer = parser
        Dim fileInfo As FileInfo = New FileInfo(dir + "\VB.xml")
        If fileInfo.Exists Then parser.CodeSnippets.LoadFile(fileInfo.FullName)
        Dim fileName As String = "myfile.cs"

        If System.IO.File.Exists(fileName) Then
            parser.FileName = fileName
            edit.LoadFile(fileName)
        End If
    End Sub
End Class