LanguageService.CreateExpansionFunction Method
Instantiates an ExpansionFunction class.
Namespace: Microsoft.VisualStudio.Package
Assemblies: Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
Syntax
‘선언
Public Overridable Function CreateExpansionFunction ( _
provider As ExpansionProvider, _
functionName As String _
) As ExpansionFunction
‘사용 방법
Dim instance As LanguageService
Dim provider As ExpansionProvider
Dim functionName As String
Dim returnValue As ExpansionFunction
returnValue = instance.CreateExpansionFunction(provider, _
functionName)
public virtual ExpansionFunction CreateExpansionFunction(
ExpansionProvider provider,
string functionName
)
public:
virtual ExpansionFunction^ CreateExpansionFunction(
ExpansionProvider^ provider,
String^ functionName
)
abstract CreateExpansionFunction :
provider:ExpansionProvider *
functionName:string -> ExpansionFunction
override CreateExpansionFunction :
provider:ExpansionProvider *
functionName:string -> ExpansionFunction
public function CreateExpansionFunction(
provider : ExpansionProvider,
functionName : String
) : ExpansionFunction
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.
Remarks
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.
Examples
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;
}
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.