DtsEventHandlers.Contains(Object) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Indica se gli elementi nella collezione possono essere accessibili usando nome, indice o ID come indice.
public:
bool Contains(System::Object ^ index);
public bool Contains(object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean
Parametri
- index
- Object
Il nome, l'indice o l'ID dell'oggetto da trovare nella collezione.
Valori restituiti
Un Booleano che indica se la collezione può essere accessibile tramite nome, indice o ID. Un valore di true indica che la collezione può essere accessibile utilizzando la sintassi DtsEventHandlers[index]. Un valore di false indica che l'indicizzazione non può essere utilizzata per recuperare elementi dalla DtsEventHandlers collezione.
Esempio
Il seguente esempio di codice recupera la DtsEventHandlers collezione, poi viene utilizzata Contains per verificare se la sintassi [x] dell'elemento può essere utilizzata sulla collezione.
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
Output di esempio:
Si può usare la sintassi degli oggetti? True
L'ID del primo gestore di eventi è: {4B9E438E-BA17-4A51-8235-3072AFF92F99}
Il nome del primo gestore eventi è: OnError