Updated: November 2007
Specifies a function to execute when the literal or object receives focus in Visual Studio.
<Function> FunctionName </Function>
The following sections describe attributes, child elements, and parent elements.
None.
Element
Description
Literal
Defines the literal fields of the code snippet that you can edit.
Object
Defines the object fields of the code snippet that you can edit.
A text value is required.
This text specifies a function to execute when the literal or object field receives focus in Visual Studio.
The Function element is only supported in Visual C# code snippets. For a complete list of supported functions, see Code Snippet Functions.
The following code example shows an example of the GenerateSwitchCases function. This function generates a case statement for each value in the enumeration specified in $expression$.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <!-- Insert Header information here. --> </Header> <Snippet> <Declarations> <Literal> <ID>expression</ID> <ToolTip>Expression to switch on.</ToolTip> <Default>switch_on</Default> </Literal> <Literal Editable="false"> <ID>cases</ID> <Function>GenerateSwitchCases($expression$)</Function> <Default>default:</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[ switch ($expression$) { $cases$ } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>