言語

ExtendedPropertyEnumerator.Current プロパティ

定義

コレクションから現在の ExtendedProperty オブジェクトを返します。

public:
 property Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ Current { Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.ExtendedProperty Current { get; }
member this.Current : Microsoft.SqlServer.Dts.Runtime.ExtendedProperty
Public ReadOnly Property Current As ExtendedProperty

プロパティ値

現在の ExtendedProperty オブジェクト。

以下のコードサンプルでは、列挙子を作成し、 Current およびMoveNextメソッドを使ってコレクションをナビゲートします。

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\Tools\Samples\1033\DataTransformationServices\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;  
            //Create the Enumerator.  
            ExtendedPropertyEnumerator myEnumerator = myExtProps.GetEnumerator();  

            Console.WriteLine("The collection contains the following values:");  
            int i = 0;  
            ExtendedProperty myExtProp;  
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))  
            {  
                myExtProp = (ExtendedProperty)myEnumerator.Current;  
                Console.WriteLine("[{0}] {1}, {2}", i++, myExtProp.ID, myExtProp.DataType);  
                Console.WriteLine("------------------------------");  
            }  
            // Reset puts the index pointer before the beginning.  
            // Do not retrieve from the collection until MoveNext is called.  
            myEnumerator.Reset();  
            myEnumerator.MoveNext();  

            // Now that the enumerator has been reset, and moved to the  
            // first item in the collection, show the first item.  
            myExtProp = (ExtendedProperty)myEnumerator.Current;  
            Console.WriteLine("The first item in the enumerator after Reset:");  
            Console.WriteLine("{0}, {1}", myExtProp.ID, myExtProp.DataType);  
            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\Tools\Samples\1033\DataTransformationServices\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   
            'Create the Enumerator.  
            Dim myEnumerator As ExtendedPropertyEnumerator =  myExtProps.GetEnumerator()   

            Console.WriteLine("The collection contains the following values:")  
            Dim i As Integer =  0   
            Dim myExtProp As ExtendedProperty  
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)  
                myExtProp = CType(myEnumerator.Current, ExtendedProperty)  
                Console.WriteLine("[{0}] {1}, {2}",i = Console.WriteLine("[{0}] {1}, {2}",i + 1  
                Console.WriteLine("------------------------------")  
            End While  
            ' Reset puts the index pointer before the beginning.  
            ' Do not retrieve from the collection until MoveNext is called.  
            myEnumerator.Reset()  
            myEnumerator.MoveNext()  

            ' Now that the enumerator has been reset, and moved to the  
            ' first item in the collection, show the first item.  
            myExtProp = CType(myEnumerator.Current, ExtendedProperty)  
            Console.WriteLine("The first item in the enumerator after Reset:")  
            Console.WriteLine("{0}, {1}", myExtProp.ID, myExtProp.DataType)  
            Console.WriteLine()  
        End Sub  
    End Class  
End Namespace  

出力例:

コレクションには以下の値が含まれています:

[0] {F3B7314E-DB1E-4CCA-A856-2E617A1B3265}、文字列

------------------------------

[1] {AA947F2D-C3B3-420F-B39E-4B7C77DAAFC0}、文字列

------------------------------

[2] {AB2CCC33-3090-4C36-B444-5B50BB481324}、文字列

------------------------------

[3] {FE85601C-4ECC-41D4-BEAA-1318DDF7EE2A}、文字列

------------------------------

[4] {4D1641B9-94EF-4144-9820-1B30ABD2214F}、弦

------------------------------

[5] {4E76A01C-BFF8-462D-AAB0-FB48B3EEAE00}、弦

------------------------------

[6] {A56842E2-11C1-487E-B670-33F25B534146}、文字列

------------------------------

リセット後の列挙子の最初の項目:

{F3B7314E-DB1E-4CCA-A856-2E617A1B3265}, 文字列

注釈

列挙子が作成された後、または リセット メソッドを呼び出した後、 MoveNext メソッドを呼び出して列挙子をコレクションの最初の要素に進める必要があります。その後、列挙子が 現在の プロパティの値を読み取ることはできません。そうでなければ、 Current は未定義で例外を投げます。

Current はまた、 MoveNext への最後の呼び出しが false返された場合、コレクション終了を示す例外をスローします。

Currentは 列挙子の位置を移動させず、 Current への連続呼び出しは MoveNext または Reset のいずれかが呼び出されるまで同じオブジェクトを返します。

列挙子は、コレクションが変更されない限り有効なままです。 コレクションに要素の追加、修正、削除などの変更が加えられると、列挙子は無効化され回復不能になります。したがって、次の MoveNext または Reset 呼び出しは InvalidOperationExceptionを投げます。 コレクションが MoveNextCurrentの呼び出し間に変更された場合、 Current はインタレータが無効化されていても設定元の要素を返します。

適用対象