ConnectionInfoEnumerator.Current プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コレクション内の現在の要素を取得します。
public:
property Microsoft::SqlServer::Dts::Runtime::ConnectionInfo ^ Current { Microsoft::SqlServer::Dts::Runtime::ConnectionInfo ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.ConnectionInfo Current { get; }
member this.Current : Microsoft.SqlServer.Dts.Runtime.ConnectionInfo
Public ReadOnly Property Current As ConnectionInfo
プロパティ値
コレクション内の現在の要素。
例
以下のコードサンプルは列挙子を作成し、 Current、 MoveNext、 Reset の各メソッドを使ってコレクションをナビゲートします。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace ConnInfos_Current
{
class Program
{
static void Main(string[] args)
{
Application dtsApplication = new Application();
ConnectionInfos connectionInfos = dtsApplication.ConnectionInfos;
//Create the Enumerator.
ConnectionInfoEnumerator ConnInfoEnum = connectionInfos.GetEnumerator();
Console.WriteLine("The collection contains the following values:");
int i = 0;
while ((ConnInfoEnum.MoveNext()) && (ConnInfoEnum.Current != null))
Console.WriteLine("[{0}] {1}", i++, ConnInfoEnum.Current.Name);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace ConnInfos_Current
Class Program
Shared Sub Main(ByVal args() As String)
Dim dtsApplication As Application = New Application()
Dim connectionInfos As ConnectionInfos = dtsApplication.ConnectionInfos
'Create the Enumerator.
Dim ConnInfoEnum As ConnectionInfoEnumerator = connectionInfos.GetEnumerator()
Console.WriteLine("The collection contains the following values:")
Dim i As Integer = 0
While (ConnInfoEnum.MoveNext()) &&(ConnInfoEnum.Current <> Nothing)
Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
End While
End Sub
End Class
End Namespace
出力例:
The collection contains the following values:
[0] Connection Manager for Files
[1] Connection Manager for SQL Server Compact
[2] Connection Manager for Multiple Flat Files
注釈
列挙子が作成された後、または Reset メソッドへの呼び出し後、 MoveNext メソッドを呼び出して列挙子をコレクションの最初の要素に進めなければ Current プロパティの値を読み取れません。そうでなければ、 Current は未定義で例外を投げます。
Current また、 MoveNext の最後の呼び出しが false返された場合も例外がスローされます。これはコレクションの末尾を示します。
Current 列挙子の位置は移動せず、 Current への連続呼び出しは MoveNext または Reset のいずれかが呼び出すまで同じオブジェクトを返します。
列挙子は、コレクションが変更されない限り有効なままです。 コレクションに要素の追加、修正、削除などの変更が加えられると、列挙子は無効化され回復不能になります。そのため、次に MoveNext か Reset に電話をかけると InvalidOperationExceptionが投げられます。
MoveNextとCurrentの呼び出し間でコレクションが変更された場合、Currentは設定された要素を返します。列挙子が無効化されていてもです。