Udostępnij za pośrednictwem


Właściwość BreakpointTargetEnumerator.Current

Pobiera bieżący BreakpointTarget obiekt kolekcja.

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

Składnia

'Deklaracja
Public ReadOnly Property Current As BreakpointTarget
    Get
'Użycie
Dim instance As BreakpointTargetEnumerator
Dim value As BreakpointTarget

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

Wartość właściwości

Typ: Microsoft.SqlServer.Dts.Runtime.BreakpointTarget
Bieżący BreakpointTarget obiekt kolekcja.

Uwagi

Po utworzeniu moduł wyliczający lub po wywołaniu zresetować 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 nieznany 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 zwracają ten sam obiekt, aż do MoveNext lub zresetować jest wywoływana.

Moduł wyliczający zachowuje ważność tak długo, jak długo kolekcja pozostaje niezmieniony.Zmian do kolekcja, takie jak dodawanie, modyfikowanie lub usuwanie elementów, moduł wyliczający jest unieważnione i odzyskane, zatem następnego wywołanie MoveNext lub zresetować generuje InvalidOperationException.Jeśli kolekcja jest zmodyfikowany między MoveNext i Current, Current zwraca element, który jest zestaw , nawet jeśli moduł wyliczający jest już unieważnionych.

Przykłady

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

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

namespace BreakpointTarget_Expression
{
    class Program
    {
        static void Main(string[] args)
        {
            Package pkg = new Package();
            TaskHost taskHost = (TaskHost)pkg.Executables.Add("STOCK:FileSystemTask");
            BreakpointTargets bptargets = pkg.GetBreakpointTargets(taskHost, false);
            // Create the enumerator.
            BreakpointTargetEnumerator myEnumerator = bptargets.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Description);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
 
Namespace BreakpointTarget_Expression
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim pkg As Package =  New Package() 
            Dim taskHost As TaskHost = CType(pkg.Executables.Add("STOCK:FileSystemTask"), TaskHost)
            Dim bptargets As BreakpointTargets =  pkg.GetBreakpointTargets(taskHost,False) 
            ' Create the enumerator.
            Dim myEnumerator As BreakpointTargetEnumerator =  bptargets.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
            Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
            End While
        End Sub
    End Class
End Namespace

Przykładowe dane wyjściowe:

Kolekcja zawiera następujące wartości:

Podział [0], gdy kontener otrzymuje zdarzenie OnPreExecute

[1] Podziału, gdy kontener otrzymuje zdarzenie OnPostExecute

[2] Podziału, gdy zdarzenie OnError odbiera kontener

[3] Podziału, gdy kontener otrzymuje zdarzenie OnWarning

[4] Podziału, gdy kontener otrzymuje zdarzenie OnInformation

[5] Podziału, gdy kontener otrzymuje zdarzenie OnTaskFailed

[6] Podziału, gdy kontener otrzymuje zdarzenie OnProgress

[7] Podziału, gdy kontener otrzymuje zdarzenie OnQueryCancel

[8] Podziału, gdy kontener otrzymuje zdarzenie OnVariableValueChanged

[9] Podziału, gdy kontener otrzymuje zdarzenie OnCustomEvent