语言

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 物品。

示例

以下代码示例通过两种方法从集合中检索一个项目。 第一种方法是利用语 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]访问集合中指定的元素。 如果返回 Containsfalse,该性质会抛出异常。 在 C# 中,此属性是类的 LogProviders 索引器。

适用于