LanguageService::CreateExpansionFunction Method (ExpansionProvider^, String^)
Instantiates an ExpansionFunction class.
Assembly: Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)
public: virtual ExpansionFunction^ CreateExpansionFunction( ExpansionProvider^ provider, String^ functionName )
Parameters
- provider
-
Type:
Microsoft.VisualStudio.Package::ExpansionProvider^
[in] The ExpansionProvider that is to use the ExpansionFunction.
- functionName
-
Type:
System::String^
[in] The name of the function the ExpansionFunction represents.
Return Value
Type: Microsoft.VisualStudio.Package::ExpansionFunction^If successful, returns an ExpansionFunction object; otherwise, returns a null value.
An expansion function presents a function embedded in a code snippet template that is to be called to provide one or more values as the template is expanded. If you are going to support expansion functions in your language's code snippets, you must derive a class from ExpansionFunction and return an instance of that class from this method.
The base method returns a null value, indicating that expansion functions are not supported by default.
This example shows one possible implementation of the CreateExpansionFunction method. The two expansion functions are implemented in two separate classes, MyClassNameExpansionFunction and MyEnumAccessTypeExpansionFunction. See the ExpansionFunction class for a more detailed version of this example.
using Microsoft.VisualStudio.Package; namespace MyLanguagePackage { public class MyLanguageService : LanguageService { public override ExpansionFunction CreateExpansionFunction(ExpansionProvider provider, string functionName) { ExpansionFunction function = null; if (String.Compare(functionName, "GetClassName", true) == 0) { function = new MyGetClassNameExpansionFunction(provider); } else if (String.Compare(functionName, "EnumAccessType", true) == 0) { function = new MyEnumAccessTypeExpansionFunction(provider); } return function; } } }