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です。