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 集合中检索项。
示例
下面的代码示例使用 Contains 方法来确定名称为“文本文件 SSIS 日志提供程序”的日志提供程序是否在集合中。 该方法返回一个 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。