Share via


LogProviders.Contains(Object) Méthode

Définition

Spécifie si un élément peut être récupéré de la collection LogProviders en utilisant l'indexation sans lever d'exception.

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

Paramètres

index
Object

Objet qui contient l'index numérique ou l'identité de l'objet dans la collection.

Retours

Boolean

Valeur booléenne qui indique si les éléments peuvent être récupérés à l’aide de l’indexation. La valeur true indique que la syntaxe LogProviders[x] peut être utilisée sans lever d’exception. La valeur false indique que l’indexation ne peut pas être utilisée pour récupérer des éléments de la LogProviders collection.

Exemples

L’exemple de code suivant utilise Contains la méthode pour déterminer si un fournisseur d’informations portant le nom « Fournisseur d’informations SSIS pour les fichiers texte » se trouve dans la collection. La méthode retourne un 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  

Exemple de sortie :

La collection contient DTS. Fournisseur LogProviderTextFile.1

Remarques

Si un fournisseur d’informations est ajouté à l’aide de la Add méthode, le Name fournisseur d’informations utilise par défaut un GUID.

S’applique à