Langage

LogProviders.Item[Object] Propriété

Définition

Obtient un LogProvider objet de la collection.

public:
 property Microsoft::SqlServer::Dts::Runtime::LogProvider ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::LogProvider ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.LogProvider this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.LogProvider
Default Public ReadOnly Property Item(index As Object) As LogProvider

Paramètres

index
Object

Le nom, la description, l’ID ou l’index de l’objet à retourner de la collection.

Valeur de propriété

Un LogProvider objet de la collection.

Exemples

L’exemple de code suivant récupère un élément de la collection en utilisant deux méthodes. La première méthode utilise la logProvs[0] syntaxe pour récupérer l’objet entier situé à la première position de la collection et le placer dans l’objet logProv . Vous pouvez désormais récupérer toutes les propriétés de l’objet logProv comme d’habitude. La seconde méthode démontre comment récupérer une propriété spécifique à partir du premier objet de la collection.

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;  

            //Using the Item method syntax of [x], obtain the  
            // first entry and a name.  
            LogProvider logProv = logProvs[0];  
            String nameOfFirstItem = logProvs[0].Name;  

            //Print the name of the log provider object   
           // located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", logProv.ID);  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem);  
        }  
    }  
}  
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   

            'Using the Item method syntax of [x], obtain the  
            ' first entry and a name.  
            Dim logProv As LogProvider =  logProvs(0)   
            Dim nameOfFirstItem As String =  logProvs(0).Name   

            'Print the name of the log provider object   
           ' located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", logProv.ID)  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem)  
        End Sub  
    End Class  
End Namespace  

Exemple de sortie :

L’identifiant de la première information de connexion est : {1E107E39-DB79-4F02-B8A7-61D88F2DEF63}

Le nom de la première information de connexion est : fournisseur de journal SSIS pour les fichiers texte

Remarques

Si l’appel à Contains la méthode retourne true, vous pouvez accéder à l’élément spécifié dans la collection en utilisant la syntaxe LogProviders[index]. Si le Contains retourne false, cette propriété crée une exception. En C#, cette propriété est l’indexeur de la LogProviders classe.

S’applique à