DtsEventHandlers.Contains(Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컬렉션 내 항목이 이름, 인덱스 또는 ID를 인덱스로 사용하여 접근할 수 있는지 여부를 나타냅니다.
public:
bool Contains(System::Object ^ index);
public bool Contains(object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean
매개 변수
- index
- Object
컬렉션에서 찾을 객체의 이름, 인덱스 또는 ID입니다.
반품
이름, 인덱스, ID로 컬렉션에 접근할 수 있는지 여부를 나타내는 불리언입니다. true의 값은 DtsEventHandlers[index] 구문을 사용하여 컬렉션에 접근할 수 있음을 나타냅니다. false 값은 인덱스를 사용해 컬렉션에서 DtsEventHandlers 항목을 검색할 수 없음을 나타냅니다.
예제
다음 코드 예시는 컬렉션을 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
샘플 출력:
아이템 문법을 사용할 수 있나요? True
첫 번째 이벤트 핸들러의 ID는 {4B9E438E-BA17-4A51-8235-3072AFF92F99}입니다.
첫 번째 이벤트 핸들러의 이름은 OnError입니다