다음을 통해 공유


ProvideLanguageCodeExpansionAttribute Constructor

Initializes a new instance of the ProvideLanguageCodeExpansionAttribute class.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)

Syntax

‘선언
Public Sub New ( _
    languageService As Object, _
    languageName As String, _
    languageResourceId As Integer, _
    languageIdentifier As String, _
    pathToSnippetIndexFile As String _
)
‘사용 방법
Dim languageService As Object
Dim languageName As String
Dim languageResourceId As Integer
Dim languageIdentifier As String
Dim pathToSnippetIndexFile As String

Dim instance As New ProvideLanguageCodeExpansionAttribute(languageService, _
    languageName, languageResourceId, _
    languageIdentifier, pathToSnippetIndexFile)
public ProvideLanguageCodeExpansionAttribute(
    Object languageService,
    string languageName,
    int languageResourceId,
    string languageIdentifier,
    string pathToSnippetIndexFile
)
public:
ProvideLanguageCodeExpansionAttribute(
    Object^ languageService, 
    String^ languageName, 
    int languageResourceId, 
    String^ languageIdentifier, 
    String^ pathToSnippetIndexFile
)
new : 
        languageService:Object * 
        languageName:string * 
        languageResourceId:int * 
        languageIdentifier:string * 
        pathToSnippetIndexFile:string -> ProvideLanguageCodeExpansionAttribute
public function ProvideLanguageCodeExpansionAttribute(
    languageService : Object, 
    languageName : String, 
    languageResourceId : int, 
    languageIdentifier : String, 
    pathToSnippetIndexFile : String
)

Parameters

  • languageService
    Type: System.Object
    [in] This is either a string containing a GUID or a type representing the class that implements the language service. The language service GUID is derived from this string or type.
  • languageName
    Type: System.String
    [in] The name of the language. This name is used in the registry for registry key and entry names.
  • languageResourceId
    Type: System.Int32
    [in] The resource ID for the localized version of the language name. This is used to present the language name in dialog boxes and other user interface elements.
  • languageIdentifier
    Type: System.String
    [in] A string containing an identifier specific to the language that is used to mark and identify code snippets.
  • pathToSnippetIndexFile
    Type: System.String
    [in] A string containing the path to the code snippets index file for the language.

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 (Managed Package Framework).

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
    {
    }
}

.NET Framework Security

See Also

Reference

ProvideLanguageCodeExpansionAttribute Class

ProvideLanguageCodeExpansionAttribute Members

Microsoft.VisualStudio.Shell Namespace

Other Resources

Support for Code Snippets (Managed Package Framework)