Udostępnij przez


Metoda DataTypeInfoEnumerator.Reset

Ustawia modułu wyliczającego do jej początkowego położenia, przed pierwszym elementem kolekcja.

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

Składnia

'Deklaracja
Public Sub Reset
'Użycie
Dim instance As DataTypeInfoEnumerator

instance.Reset()
public void Reset()
public:
virtual void Reset() sealed
abstract Reset : unit -> unit 
override Reset : unit -> unit 
public final function Reset()

Implementacje

IEnumerator.Reset()

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