次の方法で共有


ID 要素 (IntelliSense コード スニペット)

更新 : 2007 年 11 月

Literal 要素または Object 要素の一意の識別子を指定します。

<ID>
    Unique Identifier
</ID>

属性と要素

以降のセクションでは、属性、子要素、および親要素について説明します。

属性

なし。

子要素

なし。

親要素

要素

説明

Literal

編集が可能なコード スニペットのリテラル フィールドを定義します。

Object

コード スニペットの、編集が可能なオブジェクト フィールドを定義します。

テキスト値

テキスト値が必要です。

このテキストで、オブジェクトまたはリテラルの一意の識別子を指定します。

解説

同じコード スニペット内で、2 つのリテラルまたはオブジェクトの ID 要素に同じテキスト値を割り当てることはできません。

リテラルおよびオブジェクトに、end という値の ID 要素を使用することはできません。$end$ という値は、コード スニペットの挿入後のカーソル位置をマーキングする目的で予約されています。

使用例

次のコード スニペットには、ID 要素の値が SQL であるリテラルと、ID 要素の値が Connection であるオブジェクトが使用されています。Code 要素では、リテラルおよびオブジェクトが、これらの値を使用して参照されています。

<CodeSnippets xmlns="https://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>

参照

概念

コード スニペット スキーマ リファレンス