Partager via


ProvideLanguageCodeExpansionAttribute Constructor

Definition

Initializes a new instance of the ProvideLanguageCodeExpansionAttribute class.

public:
 ProvideLanguageCodeExpansionAttribute(System::Object ^ languageService, System::String ^ languageName, int languageResourceId, System::String ^ languageIdentifier, System::String ^ pathToSnippetIndexFile);
public:
 ProvideLanguageCodeExpansionAttribute(Platform::Object ^ languageService, Platform::String ^ languageName, int languageResourceId, Platform::String ^ languageIdentifier, Platform::String ^ pathToSnippetIndexFile);
 ProvideLanguageCodeExpansionAttribute(winrt::Windows::Foundation::IInspectable const & languageService, std::wstring const & languageName, int languageResourceId, std::wstring const & languageIdentifier, std::wstring const & pathToSnippetIndexFile);
public ProvideLanguageCodeExpansionAttribute (object languageService, string languageName, int languageResourceId, string languageIdentifier, string pathToSnippetIndexFile);
new Microsoft.VisualStudio.Shell.ProvideLanguageCodeExpansionAttribute : obj * string * int * string * string -> Microsoft.VisualStudio.Shell.ProvideLanguageCodeExpansionAttribute
Public Sub New (languageService As Object, languageName As String, languageResourceId As Integer, languageIdentifier As String, pathToSnippetIndexFile As String)

Parameters

languageService
Object

Language Service class. This can be a string with the value of the Guid or the Type of the language service.

languageName
String

Name of the language service. Used in the registry so cannot be localized.

languageResourceId
Int32

Resource ID of the localized name of the language service.

languageIdentifier
String

String used to identify snippets and the snippets index file.

pathToSnippetIndexFile
String

Full path to a snippets index file.

Examples

using Microsoft.VisualStudio.Shell;  

namespace MyLanguagePackage  
{  
    internal class MyConstants  
    {  
        public const string languageName           = "MyLanguage";  
        public const int    languageNameResourceID = 106;  
        public const string languageIdentifier     = "mylanguage";  
        public const string snippetsIndexFilePath   = @"%InstallRoot%\MyLanguage\SnippetsIndex.xml";  
    }  

    [ProvideCodeExpansion(typeof(MyLanguageService),            // Required  
                            MyConstants.languageName,           // Required  
                            MyConstants.languageNameResourceID, // Required  
                            MyConstants.languageIdentifier,     // Required  
                            MyConstants.snippetsIndexFilePath,  // Required  
        // Optional code expansion properties  
        SearchPaths = @"%InstallRoot%\MyLanguage\Snippets\%LCID%\Snippets;" +  
                      @"\%MyDocs%\Code Snippets\MyLanguage\My Code Snippets";  
                         )]  

    class MyLanguagePackage  
    {  
    }  
}  

Remarks

The following registry layout shows where each of the required parameters is used.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[X.Y]\Languages\  
  Language Services\  
    CodeExpansions\  
      [languageName]\  
        (Default) = reg_sz: [languageService]  
         DisplayName  = reg_sz: [languageResourceId]  
         IndexPath    = reg_sz: [pathToSnippetIndexFile]  
         LangStringID = reg_sz: [languageIdentifier]  
         Package      = reg_sz: [Package GUID]  

The [Package GUID] value is automatically obtained from the class that implements the IVsPackage interface in the assembly.

In addition to the required parameters listed in the Parameters section, the constructor also accepts optional named parameters after the required parameters. This is a special form supported only in user-defined attributes. These named parameters correspond to the public properties on this class that have both get and set operators.

For details on how the snippet index file is created and used, see Support for Code Snippets in a Legacy Language Service.

Applies to