Freigeben über


LogProviders.Contains(Object) Methode

Definition

Gibt an, ob ein Element mithilfe der Indizierung aus der LogProviders-Auflistung abgerufen werden kann, ohne eine Ausnahme auszulösen.

public:
 bool Contains(System::Object ^ index);
public bool Contains (object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean

Parameter

index
Object

Ein Objekt, das den numerischen Index oder die Identität des Objekts in der Auflistung enthält.

Gibt zurück

Boolean

Ein boolescher Wert, der angibt, ob Elemente mithilfe von Indizierung abgerufen werden können. Ein Wert von true gibt an, dass die Syntax LogProviders[x] verwendet werden kann, ohne eine Ausnahme zu auslösen. Ein Wert von false gibt an, dass die Indizierung nicht zum Abrufen von Elementen aus der LogProviders Auflistung verwendet werden kann.

Beispiele

Im folgenden Codebeispiel wird die Methode verwendet Contains , um festzustellen, ob sich ein Protokollanbieter mit dem Namen "SSIS-Protokollanbieter für Textdateien" in der Auflistung befindet. Die Methode gibt einen Boolean.

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

namespace LogProviders_Tests  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            // The package is one of the SSIS Samples.  
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";  

            // Create the Application, and load the sample.  
            Application app = new Application();  
            Package pkg = app.LoadPackage(mySample, null);  
            LogProviders logProvs = pkg.LogProviders;  

            // Search for the "SSIS log provider for Text files"  
            // in the collection  
            if (logProvs.Contains("SSIS log provider for Text files"))  
                Console.WriteLine("The collection contains {0} provider", logProvs[0].CreationName);  
            else  
                Console.WriteLine("The collection does not contain the SSIS log provider for Text files");  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace LogProviders_Tests  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            ' The package is one of the SSIS Samples.  
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"   

            ' Create the Application, and load the sample.  
            Dim app As Application =  New Application()   
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing)   
            Dim logProvs As LogProviders =  pkg.LogProviders   

            ' Search for the "SSIS log provider for Text files"  
            ' in the collection  
            If logProvs.Contains("SSIS log provider for Text files") Then  
                Console.WriteLine("The collection contains {0} provider", logProvs(0).CreationName)  
            Else   
                Console.WriteLine("The collection does not contain the SSIS log provider for Text files")  
            End If  
         End Sub  
    End Class  
End Namespace  

Beispielausgabe:

Die Auflistung enthält DTS. LogProviderTextFile.1-Anbieter

Hinweise

Wenn ein Protokollanbieter mithilfe der Add Methode hinzugefügt wird, wird der Name Protokollanbieter standardmäßig auf eine GUID festgelegt.

Gilt für: