LogProviders.Contains(Object) メソッド

定義

例外がスローされることなく、インデックスを使用して 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

コレクション内のオブジェクトの数値インデックスまたは ID を表すオブジェクトです。

戻り値

Boolean

インデックス作成を使用して項目を取得できるかどうかを示すブール値。 値 true は、例外をスローせずに LogProviders[x] 構文を使用できることを示します。 false の値は、インデックス作成を使用してコレクションから項目を取得できないことを LogProviders 示します。

次のコード サンプルでは、Contains メソッドを使用して、"SSIS 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  

サンプル出力:

The collection contains DTS.LogProviderTextFile.1 provider

注釈

ログ プロバイダーが Add メソッドを使用して追加された場合は、ログ プロバイダーの Name の既定値は GUID になります。

適用対象