LogProviders.Item[Object] 属性

定义

从集合中获取一个 LogProvider 对象。

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

参数

index
Object

要从集合中返回的对象的名称、说明、ID 或索引。

属性值

LogProvider

来自集合的一个 LogProvider 对象。

示例

下面的代码示例使用两种方法从集合中检索项。 第一种方法使用 logProvs[0] 语法检索位于集合的第一个位置的整个对象,并将其放置在对象中 logProv 。 现在可以像往常一样从 logProv 对象中检索所有属性。 第二种方法演示如何从集合中的第一个对象检索特定属性。

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  

示例输出:

第一个连接信息的 ID 为:{1E107E39-DB79-4F02-B8A7-61D88F2DEF63}

第一个连接信息的名称为:文本文件的 SSIS 日志提供程序

注解

如果调用 Contains 方法返回 true,则可以使用语法 LogProviders[index]访问集合中的指定元素。 Contains如果返回false,此属性将引发异常。 在 C# 中,此属性是 LogProviders 类的索引器。

适用于