LogProviderInfos.Item[Object] 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
LogProviderInfo从集合中获取对象。 该 Item[Object] 属性是类的默认索引器 LogProviderInfos ,允许使用 LogProviderInfos 查找值[...] 语法重写语句。
public:
property Microsoft::SqlServer::Dts::Runtime::LogProviderInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::LogProviderInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.LogProviderInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.LogProviderInfo
Default Public ReadOnly Property Item(index As Object) As LogProviderInfo
参数
- index
- Object
从集合返回对象的名称、描述、ID 或索引。
属性值
收藏中的一件 LogProviderInfo 物品。
示例
以下代码示例通过两种方法从集合中检索一个项。 第一种方法是利用语 infos[0] 法检索集合中位于第一个位置的整个对象,然后将其放入对象 lInfo 中。 你现在可以像往常一样从对象中检索所有属性 lInfo 。 第二种方法演示了如何从集合中的第一个对象中检索特定属性。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace LogProvInfoProperties
{
class Program
{
static void Main(string[] args)
{
Application app = new Application();
LogProviderInfos infos = app.LogProviderInfos;
//Using the Item method syntax of [x], obtain the first entry.
LogProviderInfo lInfo = infos[0];
String nameOfFirstItem = infos[0].Name;
//Print the name of the log provider object located at position [0].
Console.WriteLine("The ID of the first log provider is: {0}", lInfo.ID);
Console.WriteLine("The Name of the first log provider is: {0}", nameOfFirstItem);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace LogProvInfoProperties
Class Program
Shared Sub Main(ByVal args() As String)
Dim app As Application = New Application()
Dim infos As LogProviderInfos = app.LogProviderInfos
'Using the Item method syntax of [x], obtain the first entry.
Dim lInfo As LogProviderInfo = infos(0)
Dim nameOfFirstItem As String = infos(0).Name
'Print the name of the log provider object located at position [0].
Console.WriteLine("The ID of the first log provider is: {0}", lInfo.ID)
Console.WriteLine("The Name of the first log provider is: {0}", nameOfFirstItem)
End Sub
End Class
End Namespace
示例输出:
第一个日志提供者的ID是:{59B2C6A5-663F-4C20-8863-C83F9B72E2EB}
第一个日志提供者的名称是:SSIS文本文件日志提供者
注解
如果 Contains 调用方法返回 true,你可以通过语法 LogProviderInfos[index]访问集合中指定的元素。 然而,如果 Contains 方法返回 false,该性质会抛出异常。 在 C# 中,此属性是类的 LogProviderInfos 索引器。