Metoda LogProviders.Contains
Określa, czy element można pobrać z LogProviders kolekcja używając indeksowania bez niepotrzebnego wyjątek.
Przestrzeń nazw: Microsoft.SqlServer.Dts.Runtime
Zestaw: Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)
Składnia
'Deklaracja
Public Function Contains ( _
index As Object _
) As Boolean
'Użycie
Dim instance As LogProviders
Dim index As Object
Dim returnValue As Boolean
returnValue = instance.Contains(index)
public bool Contains(
Object index
)
public:
bool Contains(
Object^ index
)
member Contains :
index:Object -> bool
public function Contains(
index : Object
) : boolean
Parametry
- index
Typ: System.Object
Obiekt zawiera indeksu liczbowego lub tożsamości obiektu kolekcja.
Wartość zwracana
Typ: System.Boolean
A wartość logiczna , wskazuje, czy elementy mogą być pobierane za pomocą indeksowania.Wartość true wskazuje, że składnia LogProviders[x] może być używany bez generowania wyjątków.Wartość false wskazuje, że indeksowania może być użyty do pobieranie elementów z LogProviders kolekcja.
Uwagi
Jeśli dostawca dziennika jest dodawana przy użyciu Add metoda, Name domyślne ustawienia dostawcy dziennika na identyfikator GUID.
Przykłady
Następujący kod przykładowy używa Contains metoda w celu ustalenia, czy dostawca dziennika z "SSIS dziennika dostawcy nazw dla plików tekstowych" występuje kolekcja.Metoda zwraca wartość logiczna.
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
Przykładowe dane wyjściowe:
The collection contains DTS.LogProviderTextFile.2 provider