Udostępnij za pośrednictwem


Właściwość DataTypeInfoEnumerator.Current

Pobiera bieżący element kolekcja.

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

Składnia

'Deklaracja
Public ReadOnly Property Current As Object
    Get
'Użycie
Dim instance As DataTypeInfoEnumerator
Dim value As Object

value = instance.Current
public Object Current { get; }
public:
virtual property Object^ Current {
    Object^ get () sealed;
}
abstract Current : Object
override Current : Object
final function get Current () : Object

Wartość właściwości

Typ: System.Object
Bieżący element kolekcja.

Implementacje

IEnumerator.Current

Uwagi

Po utworzeniu moduł wyliczający lub po wywołaniu Reset metody, MoveNext Metoda musi zostać wywołana, aby przejść do pierwszego elementu kolekcja przed odczytywania wartości moduł wyliczający Current właściwość; w przeciwnym razie Current jest niezdefiniowany i zgłasza wyjątek.

Currentrównież zgłasza wyjątek, jeśli wywołanie ostatniego MoveNext zwracane false, które wskazuje koniec kolekcja.

Currentnie przenosi pozycja modułu wyliczającego i kolejne wywołania Current zwraca ten sam obiekt, aż do MoveNext lub Reset jest wywoływana.

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.Jeśli kolekcja jest zmodyfikowany między wywołania MoveNext i Current, Current 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, MoveNext, i Reset metod nawigacji przez kolekcja.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace DataTypeInfos_GetEnum_Current
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the DataTypeInfos collection.
            DataTypeInfos dataInfos = new Application().DataTypeInfos;

            //Create the Enumerator.
            DataTypeInfoEnumerator myEnumerator = dataInfos.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            DataTypeInfo dtiObject;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
            {
                dtiObject = (DataTypeInfo)myEnumerator.Current;
                Console.WriteLine("[{0}] {1} {2}", i++, dtiObject.TypeName, dtiObject.TypeEnumName);
            }
            // 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.
            dtiObject = (DataTypeInfo)myEnumerator.Current;
            Console.WriteLine("The first item in the enumerator after Reset:");
            Console.WriteLine("{0}, {1}", dtiObject.TypeName, dtiObject.TypeEnumName);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace DataTypeInfos_GetEnum_Current
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create the DataTypeInfos collection.
            Dim dataInfos As DataTypeInfos =  New Application().DataTypeInfos 
 
            'Create the Enumerator.
            Dim myEnumerator As DataTypeInfoEnumerator =  dataInfos.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            Dim dtiObject As DataTypeInfo
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
                dtiObject = CType(myEnumerator.Current, DataTypeInfo)
                Console.WriteLine("[{0}] {1} {2}",i = Console.WriteLine("[{0}] {1} {2}",i + 1
            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.
            dtiObject = CType(myEnumerator.Current, DataTypeInfo)
            Console.WriteLine("The first item in the enumerator after Reset:")
            Console.WriteLine("{0}, {1}", dtiObject.TypeName, dtiObject.TypeEnumName)
        End Sub
    End Class
End Namespace

Przykładowe dane wyjściowe:

Kolekcja zawiera następujące wartości:

Pływak [0] DT_R4

[1] podwójnej precyzji pływak DT_R8

[2] waluty DT_CY

[3] Data DT_DATE

[4] wartość logiczna DT_BOOL

[5] DT_DECIMAL dziesiętne

[6] jednobajtowe całkowita DT_I1

[7] liczba całkowita bez znaku jednobajtowe DT_UI1

[8] dwubajtowy całkowita DT_I2

[9] dwubajtowy niepodpisane całkowitą DT_UI2

[10] czterech bajtów Całkowita DT_I4

[11] czwartego bajtu niepodpisane całkowitą DT_UI4

[12] ośmiu bajtów Całkowita DT_I8

[13] ośmiu bajtów niepodpisane całkowitą DT_UI8

[14] Sygnatura czasowa pliku DT_FILETIME

[15] identyfikator unikatowy DT_GUID

[16] strumienia bajtów DT_BYTES

[17] ciąg DT_STR

[18] Ciąg Unicode DT_WSTR

[19] DT_NUMERIC numeryczne

[20] Data bazy danych DT_DBDATE

[21] czas bazy danych DT_DBTIME

[22] sygnatury czasowej bazy danych DT_DBTIMESTAMP

[23] obrazu DT_IMAGE

[24] strumień tekstu DT_TEXT

[25] Strumień tekstu Unicode DT_NTEXT

Pierwszy element modułu wyliczającego po resetowania:

Pływak DT_R4