共用方式為


ExtendedProperties.GetEnumerator 方法

Returns an ExtendedPropertyEnumerator for iterating over the ExtendedProperties collection.

命名空間:  Microsoft.SqlServer.Dts.Runtime
組件:  Microsoft.SqlServer.ManagedDTS (在 Microsoft.SqlServer.ManagedDTS.dll 中)

語法

'宣告
Public Function GetEnumerator As ExtendedPropertyEnumerator
'用途
Dim instance As ExtendedProperties 
Dim returnValue As ExtendedPropertyEnumerator 

returnValue = instance.GetEnumerator()
public ExtendedPropertyEnumerator GetEnumerator()
public:
ExtendedPropertyEnumerator^ GetEnumerator()
member GetEnumerator : unit -> ExtendedPropertyEnumerator
public function GetEnumerator() : ExtendedPropertyEnumerator

傳回值

型別:Microsoft.SqlServer.Dts.Runtime.ExtendedPropertyEnumerator
An ExtendedPropertyEnumerator enumerator for iterating over the collection.

範例

The following code sample creates an ExtendedPropertyEnumerator using the GetEnumerator method, and then iterates over the collection.

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;
            //Create the enumerator.
            ExtendedPropertyEnumerator myEnumerator = myExtProps.GetEnumerator();
            
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            ExtendedProperty myExtProp;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
            {
                myExtProp = (ExtendedProperty)myEnumerator.Current;
                Console.WriteLine("[{0}] {1}, {2}", i++, myExtProp.ID, myExtProp.DataType);
                Console.WriteLine("------------------------------");
            }
            // Reset puts the index pointer before the beginning.
            // Do not retrieve from the collection until MoveNext is called.
            myEnumerator.Reset();
            myEnumerator.MoveNext();

            // Now that the enumerator has been reset, and moved to the
            // first item in the collection, show the first item.
            myExtProp = (ExtendedProperty)myEnumerator.Current;
            Console.WriteLine("The first item in the enumerator after Reset:");
            Console.WriteLine("{0}, {1}", myExtProp.ID, myExtProp.DataType);
            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 
            'Create the enumerator.
            Dim myEnumerator As ExtendedPropertyEnumerator =  myExtProps.GetEnumerator() 
 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            Dim myExtProp As ExtendedProperty
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
                myExtProp = CType(myEnumerator.Current, ExtendedProperty)
                Console.WriteLine("[{0}] {1}, {2}",i = Console.WriteLine("[{0}] {1}, {2}",i + 1
                Console.WriteLine("------------------------------")
            End While
            ' Reset puts the index pointer before the beginning.
            ' Do not retrieve from the collection until MoveNext is called.
            myEnumerator.Reset()
            myEnumerator.MoveNext()
 
            ' Now that the enumerator has been reset, and moved to the
            ' first item in the collection, show the first item.
            myExtProp = CType(myEnumerator.Current, ExtendedProperty)
            Console.WriteLine("The first item in the enumerator after Reset:")
            Console.WriteLine("{0}, {1}", myExtProp.ID, myExtProp.DataType)
            Console.WriteLine()
        End Sub
    End Class
End Namespace

Sample Output:

The collection contains the following values:

[0] {F3B7314E-DB1E-4CCA-A856-2E617A1B3265}, String

------------------------------

[1] {AA947F2D-C3B3-420F-B39E-4B7C77DAAFC0}, String

------------------------------

[2] {AB2CCC33-3090-4C36-B444-5B50BB481324}, String

------------------------------

[3] {FE85601C-4ECC-41D4-BEAA-1318DDF7EE2A}, String

------------------------------

[4] {4D1641B9-94EF-4144-9820-1B30ABD2214F}, String

------------------------------

[5] {4E76A01C-BFF8-462D-AAB0-FB48B3EEAE00}, String

------------------------------

[6] {A56842E2-11C1-487E-B670-33F25B534146}, String

------------------------------

The first item in the enumerator after Reset:

{F3B7314E-DB1E-4CCA-A856-2E617A1B3265}, String

請參閱

參考

ExtendedProperties 類別

Microsoft.SqlServer.Dts.Runtime 命名空間