LogProviders.Contains(Object) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
例外をスローせずにインデックスを用いて LogProviders コレクションからアイテムを取得できるかどうかを指定します。
public:
bool Contains(System::Object ^ index);
public bool Contains(object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean
パラメーター
- index
- Object
コレクション内のオブジェクトの数値インデックスや識別子を含むオブジェクト。
返品
インデックスを使ってアイテムを取得できるかどうかを示すブール値です。 trueの値は、LogProviders[x]という構文を例外をスローせずに使用できることを示します。 falseの値は、インデックス作成で LogProviders コレクションからアイテムを取得することができないことを示します。
例
以下のコードサンプルは、「SSIS Contains log provider for Text files」という名前のログプロバイダーがコレクションに含まれているかどうかを判定するために、この方法を用いています。 メソッドは Booleanを返します。
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;
// Search for the "SSIS log provider for Text files"
// in the collection
if (logProvs.Contains("SSIS log provider for Text files"))
Console.WriteLine("The collection contains {0} provider", logProvs[0].CreationName);
else
Console.WriteLine("The collection does not contain the SSIS log provider for Text files");
}
}
}
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
' Search for the "SSIS log provider for Text files"
' in the collection
If logProvs.Contains("SSIS log provider for Text files") Then
Console.WriteLine("The collection contains {0} provider", logProvs(0).CreationName)
Else
Console.WriteLine("The collection does not contain the SSIS log provider for Text files")
End If
End Sub
End Class
End Namespace
出力例:
このコレクションにはDTSが含まれています。LogProviderTextFile.1 プロバイダー
注釈
Addメソッドでログプロバイダーを追加する場合、そのログプロバイダーのNameはデフォルトでGUIDとなります。