ExpansionFunction.GetArgument Method (Int32)


Gets the specified argument.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public string GetArgument(
	int index


Type: System.Int32

[in] The position in the arguments array to get.

Return Value

Type: System.String

The specified argument if it exists, otherwise null.

This helper method is called from your implementation of the GetCurrentValue method to retrieve the value of the specified argument. If you want to access an argument by name, call the GetFieldValue method with the name of the argument.

An argument can be either an explicit value or a variable. A variable is surrounded by dollar signs ("$myvar$") and represents an expression in the code snippet template that has a value or another expansion function assigned to it. If an argument is not surrounded by dollar signs or is surrounded by single or double quotes, then the argument is taken literally as the value for that argument.

For example, given the function declaration (as seen in a code snippet template file) <function>MyFunction($expr1$,"value1",'value2',value3)</function>, expr1 is a variable that contains a value to be returned, value1, value2, and value3 are all literal values that are returned as is for those arguments.

This method calls the GetFieldValue method to obtain the value of a variable. If the variable cannot be resolved to a value, the name of the variable is surrounded by dollar signs and returned as the value.

Return to top