語言

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 索引器。

適用於