Aracılığıyla paylaş


DtsEventHandlerEnumerator.Current Özelliği

Geçerli öğe alır koleksiyon.

Ad Alanı:  Microsoft.SqlServer.Dts.Runtime
Derleme:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS içinde.dll)

Sözdizimi

'Bildirim
Public ReadOnly Property Current As DtsEventHandler
    Get
'Kullanım
Dim instance As DtsEventHandlerEnumerator
Dim value As DtsEventHandler

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

Özellik Değeri

Tür: Microsoft.SqlServer.Dts.Runtime.DtsEventHandler
Geçerli öğe koleksiyon.

Açıklamalar

Bir Numaralandırıcı oluşturulduktan sonra veya çağrısı yapıldıktan sonra sıfırlama yöntem, MoveNext yönteminin çağrıldığı, numaralayıcı ilk öğe için ilerlemek için koleksiyon değeri okunurken önce Current özellik; Aksi takdirde, Current tanımsız ve atar bir özel durum.

CurrentSon çağrısı, aynı zamanda bir istisna atar MoveNext döndürülen yanlış, sonuna kadar gösterir koleksiyon.

CurrentNumaralayıcı ve art arda çağrılar konumunu taşımak Current dönmek kadar ya da ayný nesneye MoveNext veya sıfırlama denir.

Bir Numaralandırıcı geçerli kalır sürece koleksiyon değişmeden kalır.Koleksiyon, ekleme, değiştirme veya öğeleri silme gibi değişiklikler yapılırsa numaralayıcı geçersiz kılınır ve Düzeltilemeyen olur; Böylece, sonraki çağrı MoveNext veya Reset atar bir InvalidOperationException.Koleksiyon çağrıları arasında değiştirilirse MoveNext ve Current, Current Bu öğeyi döndürür küme kadar numaralayıcı getirildi bile.

Örnekler

Aşağıdaki kod örneği, iki olay işleyicilerini paket oluşturur.Bir olay işleyicisi için iki görevi eklenir.Daha sonra bir DtsEventHandlerEnumerator oluşturulur ve kullanan Current ve MoveNext yöntemleri üzerinde koleksiyon gezinmek için.

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

namespace DtsEventHandler_API
{
    class Program
    {
        static void Main(string[] args)
        {
            Package pkg = new Package();

            // Set up a DtsEventHandler for the OnError event of the package.
            DtsEventHandler dtsEHOE = (DtsEventHandler)pkg.EventHandlers.Add("OnError");
            DtsEventHandler dtsEHW = (DtsEventHandler)pkg.EventHandlers.Add("OnWarning");

            // When an OnError Event occurs, the Executables collection contains
            // the items to run. For this example, there will be a SendMailtTask
            // and a BulkInsertTask with a precedence constraint between them.
            Executable dtsEH1 = dtsEHOE.Executables.Add("STOCK:SendMailTask");
            TaskHost th = (TaskHost)dtsEH1;
            SendMailTask smTask = (SendMailTask)th.InnerObject;
            smTask.Subject = "Send Mail task";
            
            // Add a second executable to the DtsEventHandler.
            Executable dtsEH2 = dtsEHOE.Executables.Add("STOCK:BulkInsertTask");
            TaskHost th2 = (TaskHost)dtsEH2;

            //Create the Enumerator. Since we added the DtsEventhandler to the 
            // package, then that's where to get the EventHandlers collection.
            DtsEventHandlerEnumerator myEnum = pkg.EventHandlers.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            while ((myEnum.MoveNext()) && (myEnum.Current != null))
                Console.WriteLine("[{0}] {1}", i++, myEnum.Current.Name);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
 
Namespace DtsEventHandler_API
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim pkg As Package =  New Package() 
 
            ' Set up a DtsEventHandler for the OnError event of the package.
            Dim dtsEHOE As DtsEventHandler = CType(pkg.EventHandlers.Add("OnError"), DtsEventHandler)
            Dim dtsEHW As DtsEventHandler = CType(pkg.EventHandlers.Add("OnWarning"), DtsEventHandler)
 
            ' When an OnError Event occurs, the Executables collection contains
            ' the items to run. For this example, there will be a SendMailtTask
            ' and a BulkInsertTask with a precedence constraint between them.
            Dim dtsEH1 As Executable =  dtsEHOE.Executables.Add("STOCK:SendMailTask") 
            Dim th As TaskHost = CType(dtsEH1, TaskHost)
            Dim smTask As SendMailTask = CType(th.InnerObject, SendMailTask)
            smTask.Subject = "Send Mail task"
 
            ' Add a second executable to the DtsEventHandler.
            Dim dtsEH2 As Executable =  dtsEHOE.Executables.Add("STOCK:BulkInsertTask") 
            Dim th2 As TaskHost = CType(dtsEH2, TaskHost)
 
            'Create the Enumerator. Since we added the DtsEventhandler to the 
            ' package, then that's where to get the EventHandlers collection.
            Dim myEnum As DtsEventHandlerEnumerator =  pkg.EventHandlers.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            While (myEnum.MoveNext()) &&(myEnum.Current <> Nothing)
            Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
            End While
        End Sub
    End Class
End Namespace

Örnek Çıktı:

Koleksiyon aşağıdaki değerleri içerir:

[0] OnError

[1] OnWarning