Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Object Element (IntelliSense Code Snippets)

Defines the objects of the code snippet that you can edit.

<CodeSnippets>
   <CodeSnippet>
     <Snippet>
       <Declarations>
         <Object>
<Object Editable="true/false">
    <ID>... </ID>
    <Type>... </Type>
    <ToolTip>... </ToolTip>
    <Default>... </Default>
    <Function>... </Function>
</Object>

The following sections describe attributes, child elements, and parent elements.

Attributes

Element

Description

Editable

Optional Boolean attribute.

Specifies whether or not the object can be edited after the code snippet is inserted. The default value of this attribute is true.

Child Elements

Element

Description

Default

Required element.

Specifies the object's default value when the code snippet is inserted. There must be exactly one Default element in a Object element.

Function

Optional element.

Specifies a function to execute when the object receives focus in Visual Studio. There may be zero or one Function elements in a Object element.

ID

Required element.

Specifies a unique identifier for the object. There must be exactly one ID element in an Object element.

Tooltip

Optional element.

Describes the expected value and usage of the object. There may be zero or one Tooltip elements in an Object element.

Type

Required element.

Specifies the type of the object. There must be exactly one Type element in an Object element.

Parent Elements

Element

Description

Declarations

Contains the literals and objects that make up the parts of a code snippet that you can edit.

The Object element is used to identify an item that is required by the code snippet but is likely to be defined outside of the snippet itself. For example, Windows Forms controls, ASP.NET controls, object instances, and type instances should be declared as objects. Object declarations require that a type be specified, which is done with the Type element.

The following code example shows how to declare a SqlConnection object with an ID element value of Connection. The object is referenced in the Code element by using the default delimiter. In this example, the object is referenced with $Connection$.

Literals and objects cannot contain an ID element with a value of end. The value $end$ is reserved, and is used to mark the location to place the cursor after the code snippet is inserted.

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Create a data adapter</Title>
            <Description>Creates a SqlDataAdapter object.</Description>
            <Author>Microsoft Corporation</Author>
            <Shortcut>createadapter</Shortcut>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>SQL</ID>
                    <ToolTip>Replace with a SQL connection string.</ToolTip>
                    <Default>"SQL connection string"</Default>
                </Literal>
                <Object>
                    <ID>Connection</ID>
                    <Type>System.Data.SqlClient.SqlConnection</Type>
                    <ToolTip>Replace with a connection object in your application.</ToolTip>
                    <Default>dcConnection</Default>
                </Object>
            </Declarations>
            <Code Language="CSharp">
                <![CDATA[
                    daCustomers = new SqlClient.SqlDataAdapter();
                    selectCommand = new SqlClient.SqlCommand($SQL$);
                    daCustomers.SelectCommand = selectCommand;
                    daCustomers.SelectCommand.Connection = $Connection$;
                ]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.