Udostępnij za pośrednictwem


Właściwość ExtendedPropertyEnumerator.Current

Zwraca bieżący ExtendedProperty obiekt z kolekcja.

Przestrzeń nazw:  Microsoft.SqlServer.Dts.Runtime
Zestaw:  Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)

Składnia

'Deklaracja
Public ReadOnly Property Current As ExtendedProperty
    Get
'Użycie
Dim instance As ExtendedPropertyEnumerator
Dim value As ExtendedProperty

value = instance.Current
public ExtendedProperty Current { get; }
public:
property ExtendedProperty^ Current {
    ExtendedProperty^ get ();
}
member Current : ExtendedProperty
function get Current () : ExtendedProperty

Wartość właściwości

Typ: Microsoft.SqlServer.Dts.Runtime.ExtendedProperty
Bieżący ExtendedProperty obiektu.

Uwagi

Po utworzeniu moduł wyliczający lub po wywołaniu zresetować metody, MoveNext metoda musi zostać wywołana, aby przejść do pierwszego elementu kolekcja modułu wyliczającego, zanim modułu wyliczającego można odczytać wartości bieżącego właściwość; w przeciwnym razie bieżącego jest niezdefiniowany i zgłasza wyjątek.

Bieżący również zgłasza wyjątek, jeśli wywołanie ostatniego MoveNext zwrócił false, wskazuje koniec kolekcja.

Bieżący nie przenosi pozycja modułu wyliczającego i kolejne wywołania bieżącego zwraca ten sam obiekt, aż do MoveNext lub zresetować nosi.

Moduł wyliczający zachowuje ważność tak długo, jak długo kolekcja pozostaje niezmieniony.Jeśli zmiany zostaną wprowadzone do kolekcja, takie jak dodawanie, modyfikowanie lub usuwanie elementów, moduł wyliczający jest unieważniona i staje się odzyskane; Dlatego kolejne wywołanie MoveNext lub zresetować generuje InvalidOperationException.Kolekcja jest modyfikowany między wywołaniami MoveNext i bieżącego, bieżącego zwraca element, który jest zestaw , nawet jeśli moduł wyliczający został unieważniony.

Przykłady

Poniższy przykładowy kod tworzy moduł wyliczający, a następnie używa Current i metody MoveNext przejść przez kolekcja.

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

Przykładowe dane wyjściowe:

Kolekcja zawiera następujące wartości:

{F3B7314E-DB1E-4CCA-A856-2E617A1B3265} [0] ciąg

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

[1] {AA947F2D-C3B3-420F-B39E-4B7C77DAAFC0} ciąg

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

[2] {AB2CCC33-3090-4 C 36-B444-5B50BB481324}, String

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

[3] {FE85601C-4ECC-41 D 4-BEAA-1318DDF7EE2A}, String

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

[4] {4D1641B9-94EF-4144-9820-1B30ABD2214F} ciąg

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

[5] {4E76A01C-BFF8-462D-AAB0-FB48B3EEAE00} ciąg

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

[6] {A56842E2-11 C 1-487E-B670-33F25B534146}, String

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

Pierwszy element modułu wyliczającego po resetowania:

{F3B7314E-DB1E-4CCA-A856-2E617A1B3265} ciąg