ExtendedProperties.Item[Object] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從集合中取得一個 ExtendedProperty 物件。
public:
property Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.ExtendedProperty this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.ExtendedProperty
Default Public ReadOnly Property Item(index As Object) As ExtendedProperty
參數
- index
- Object
要回傳物件的 ExtendedProperty 名稱、描述、ID 或索引。
屬性值
收藏中的一件 ExtendedProperty 物品。
範例
以下程式碼範例使用兩種方法從集合中取得一個項目。 第一種方法是利用語 myExtProps[0] 法擷取集合中位於第一位置的整個物件並將其放入物件中 myExtProp 。 你現在可以像平常一樣從物件中取得所有屬性 myExtProp 。 第二種方法示範如何從集合中的第一個物件中取得特定屬性 DataType。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace ExtendedProperties_Testing
{
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);
// Get the extended properties collection from the package.
ExtendedProperties myExtProps = pkg.ExtendedProperties;
//Using the Item method syntax of [x], obtain the
// entire first entry, and then just the name.
ExtendedProperty myExtProp = myExtProps[0];
String dataTypeOfFirstItem = myExtProps[0].DataType.ToString();
//Print the name of the extended property
//located at position [0].
Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID);
Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem);
Console.WriteLine();
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace ExtendedProperties_Testing
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)
' Get the extended properties collection from the package.
Dim myExtProps As ExtendedProperties = pkg.ExtendedProperties
'Using the Item method syntax of [x], obtain the
' entire first entry, and then just the name.
Dim myExtProp As ExtendedProperty = myExtProps(0)
Dim dataTypeOfFirstItem As String = myExtProps(0).DataType.ToString()
'Print the name of the extended property
'located at position [0].
Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID)
Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem)
Console.WriteLine()
End Sub
End Class
End Namespace
範例輸出:
第一個項目的 ID 為:{F3B7314E-DB1E-4CCA-A856-2E617A1B3265}
第一個項目的資料型態為:String
備註
如果呼叫 Contains 方法回傳 true,你可以透過語法 ExtendedProperties[index]存取集合中指定的元素。 然而,如果方法 Contains 回傳 false,這個特性會拋出例外。 在 C# 中,這個屬性就是類別的 ExtendedProperties 索引器。