LogProviderInfoEnumerator.Current 属性

定义

从集合获取当前的 LogProviderInfo 元素。

public:
 property Microsoft::SqlServer::Dts::Runtime::LogProviderInfo ^ Current { Microsoft::SqlServer::Dts::Runtime::LogProviderInfo ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.LogProviderInfo Current { get; }
member this.Current : Microsoft.SqlServer.Dts.Runtime.LogProviderInfo
Public ReadOnly Property Current As LogProviderInfo

属性值

LogProviderInfo

当前的 LogProviderInfo 对象。

示例

下面的代码示例创建一个枚举器,然后使用 CurrentMoveNext 和 Reset 方法在集合上导航。

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;  

        //Create the Enumerator.  
        LogProviderInfoEnumerator myEnumerator = infos.GetEnumerator();  
        Console.WriteLine("The collection contains the following values:");  
        //Iterate over the collection using the indexer instead of foreach.  
        int i = 0;  
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))  
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Name);  

        }  
    }  
}  
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   

            'Create the Enumerator.  
            Dim myEnumerator As LogProviderInfoEnumerator =  infos.GetEnumerator()   
            Console.WriteLine("The collection contains the following values:")  
            'Iterate over the collection using the indexer instead of foreach.  
            Dim i As Integer =  0   
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)  
              Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1  
            End While  
        End Sub  
    End Class  
End Namespace  

示例输出:

集合包含以下值:

[0] 文本文件的 SSIS 日志提供程序

[1] SQL Server Profiler的 SSIS 日志提供程序

[2] SQL Server的 SSIS 日志提供程序

[3] Windows 事件日志的 SSIS 日志提供程序

[4] XML 文件的 SSIS 日志提供程序

注解

创建枚举器或调用 Reset 方法后, MoveNext 必须调用该方法才能将枚举器推进到集合的第一个元素,然后枚举器才能读取属性的值 Current ;否则, Current 未定义并引发异常。

Current如果最后一次调用返回MoveNextfalse,则也会引发异常,该调用指示集合的末尾。

Current不会移动枚举器的位置,并且连续调用以Current返回相同的对象,直到调用或MoveNextReset调用。

只要集合保持不变,枚举器就仍有效。 如果对集合进行了更改(例如添加、修改或删除元素),则枚举器将失效并变为不可恢复;因此,下一次调用 MoveNextReset 引发一个 InvalidOperationException。 如果对集合的调用 MoveNextCurrent调用之间修改, Current 则返回它设置为的元素,即使枚举器已失效。

适用于