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
Объект, содержащий числовой индекс или идентичность объекта в коллекции.
Возвращаемое значение
Булевое изображение, указывающее, можно ли получить элементы с помощью индексации. Значение 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
Пример вывода:
Коллекция содержит DTS. LogProviderTextFile.1 provider
Комментарии
Если провайдер логов добавлен с помощью этого Add метода, Name провайдер логов по умолчанию использует GUID.