ExtendedProperties.Item プロパティ

ExtendedProperty オブジェクトをコレクションから取得します。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public ReadOnly Default Property Item ( _
    index As Object _
) As ExtendedProperty 
    Get
'使用
Dim instance As ExtendedProperties 
Dim index As Object 
Dim value As ExtendedProperty 

value = instance(index)
public ExtendedProperty this[
    Object index
] { get; }
public:
property ExtendedProperty^ default[Object^ index] {
    ExtendedProperty^ get (Object^ index);
}
member Item : ExtendedProperty
JScript はインデックス化されたプロパティの使用をサポートしていますが、新規の宣言はサポートしていません。

パラメーター

プロパティ値

型: Microsoft.SqlServer.Dts.Runtime.ExtendedProperty
コレクションからの ExtendedProperty オブジェクトです。

説明

Contains メソッドの呼び出しが true を返す場合、ExtendedProperties[index] 構文を使用することにより、コレクション内の指定した要素にアクセスできます。 ただし、Contains メソッドが false を返す場合、このプロパティは例外をスローします。 C# の場合、このプロパティは ExtendedProperties クラスのインデクサーとなります。

使用例

次のコード サンプルでは、2 つのメソッドを使用して、コレクションから項目を取得します。 最初のメソッドでは、myExtProps[0] 構文を使用して、コレクションの先頭に格納されたオブジェクト全体を取得し、myExtProp オブジェクトに格納します。 これによって、myExtProp オブジェクトからすべてのプロパティを通常どおり取得できるようになります。 2 番目のメソッドでは、コレクションの最初のオブジェクトから特定のプロパティ DataType を取得します。

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace ExtendedProperties_Testing
{
    class Program
    {
        static void Main(string[] args)
        {
            // The package is one of the SSIS samples.
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";
            // Create the application, and load the sample.
            Application app = new Application();
            Package pkg = app.LoadPackage(mySample, null);

            // Get the extended properties collection from the package.
            ExtendedProperties myExtProps = pkg.ExtendedProperties;

            //Using the Item method syntax of [x], obtain the
            // entire first entry, and then just the name.
            ExtendedProperty myExtProp = myExtProps[0];
            String dataTypeOfFirstItem = myExtProps[0].DataType.ToString();

            //Print the name of the extended property 
           //located at position [0].
            Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID);
            Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem);
            Console.WriteLine();
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace ExtendedProperties_Testing
    Class Program
        Shared  Sub Main(ByVal args() As String)
            ' The package is one of the SSIS samples.
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx" 
            ' Create the application, and load the sample.
            Dim app As Application =  New Application() 
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing) 
 
            ' Get the extended properties collection from the package.
            Dim myExtProps As ExtendedProperties =  pkg.ExtendedProperties 
 
            'Using the Item method syntax of [x], obtain the
            ' entire first entry, and then just the name.
            Dim myExtProp As ExtendedProperty =  myExtProps(0) 
            Dim dataTypeOfFirstItem As String =  myExtProps(0).DataType.ToString() 
 
            'Print the name of the extended property 
           'located at position [0].
            Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID)
            Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem)
            Console.WriteLine()
        End Sub
    End Class
End Namespace

サンプル出力:

The ID of the first item is: {F3B7314E-DB1E-4CCA-A856-2E617A1B3265}

The DataType of the first item is: String

関連項目

参照

ExtendedProperties クラス

Microsoft.SqlServer.Dts.Runtime 名前空間