DtsEventHandlers.Item[Object] 속성

정의

컬렉션에서 DtsEventHandler 개체를 가져옵니다.

public:
 property Microsoft::SqlServer::Dts::Runtime::DtsEventHandler ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::DtsEventHandler ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.DtsEventHandler this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.DtsEventHandler
Default Public ReadOnly Property Item(index As Object) As DtsEventHandler

매개 변수

index
Object

컬렉션에서 반환할 DtsEventHandler 개체의 이름, ID 또는 인덱스입니다.

속성 값

컬렉션의 DtsEventHandler 개체입니다.

예제

다음 코드 예제에서는 컬렉션을 검색 DtsEventHandlers 한 다음 Contains 컬렉션에서 항목 구문을 [x] 사용할 수 있는지 확인합니다.

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

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    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");  

            // Create the DtsEventHandlers collection.  
            DtsEventHandlers dtsEHColls = pkg.EventHandlers;  

            // Use the Contains method to see if the item[x] syntax can be used.  
            Boolean dtsContains = dtsEHColls.Contains(0);  
            Console.WriteLine("Item syntax can be used?  {0}", dtsContains);  

            //Using the Item method syntax of [x], obtain the first entry and a name.  
            DtsEventHandler dtsEHFirstEntry = dtsEHColls[0];  
            String nameOfFirstItem = dtsEHColls[0].Name;  

            //Print the name of the log provider object located at position [0].  
            Console.WriteLine("The ID of the first event handler is: {0}", dtsEHFirstEntry.ID);  
            Console.WriteLine("The Name of the first event handler is: {0}", nameOfFirstItem);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace Microsoft.SqlServer.SSIS.Samples  
    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)  

            ' Create the DtsEventHandlers collection.  
            Dim dtsEHColls As DtsEventHandlers =  pkg.EventHandlers   

            ' Use the Contains method to see if the item[x] syntax can be used.  
            Dim dtsContains As Boolean =  dtsEHColls.Contains(0)   
            Console.WriteLine("Item syntax can be used?  {0}", dtsContains)  

            'Using the Item method syntax of [x], obtain the first entry and a name.  
            Dim dtsEHFirstEnTry As DtsEventHandler =  dtsEHColls(0)   
            Dim nameOfFirstItem As String =  dtsEHColls(0).Name   

            'Print the name of the log provider object located at position [0].  
            Console.WriteLine("The ID of the first event handler is: {0}", dtsEHFirstEnTry.ID)  
            Console.WriteLine("The Name of the first event handler is: {0}", nameOfFirstItem)  
        End Sub  
    End Class  
End Namespace  

샘플 출력:

항목 구문을 사용할 수 있나요? 참

첫 번째 이벤트 처리기의 ID는 {4B9E438E-BA17-4A51-8235-3072AFF92F99}입니다.

첫 번째 이벤트 처리기의 이름은 OnError입니다.

설명

메서드 호출이 Contains 반환 true되는 경우 구문을 DtsEventHandlers[index]사용하여 컬렉션에서 지정된 요소에 액세스할 수 있습니다. 메서드가 Contains 반환 false되면 이 속성은 예외를 throw합니다. C#에서 이 속성은 DtsEventHandlers 클래스의 인덱서입니다.

적용 대상