Compartir a través de


Configurations.GetEnumerator Method

Returns an enumerator for iterating over the Configurations collection.

Espacio de nombres: Microsoft.SqlServer.Dts.Runtime
Ensamblado: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Sintaxis

'Declaración
Public Function GetEnumerator As ConfigurationEnumerator
public ConfigurationEnumerator GetEnumerator ()
public:
ConfigurationEnumerator^ GetEnumerator ()
public ConfigurationEnumerator GetEnumerator ()
public function GetEnumerator () : ConfigurationEnumerator

Valor devuelto

A ConfigurationEnumerator enumerator.

Ejemplo

The following code example creates a ConfigurationEnumerator, then iterates over the collection, showing configuration names.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace Configurations_API
{
    class Program
    {
        static void Main(string[] args)
        {
            Package p = new Package();
            
            Configuration conf1 = p.Configurations.Add();
            conf1.ConfigurationString = "Conf1 Configuration String";
            conf1.ConfigurationType = DTSConfigurationType.EnvVariable;
            conf1.Description = "Some description for Conf1 configuration";
            conf1.Name = "Conf1";
            conf1.PackagePath = "A Variable Name in configuration Conf1";

            Configuration conf2 = p.Configurations.Add();
            conf2.ConfigurationString = "Conf2 Configuration String";
            conf2.ConfigurationType = DTSConfigurationType.ConfigFile;
            conf2.Description = "Some description for Conf2 configuration";
            conf2.Name = "Conf2";
            conf2.PackagePath = "A Variable Name in configuration Conf2";

            Configuration conf3 = p.Configurations.Add();
            conf3.ConfigurationString = "Conf3 Configuration String2";
            conf3.ConfigurationType = DTSConfigurationType.RegEntry;
            conf3.Description = "Conf3 description for Conf3 configuration2";
            conf3.Name = "Conf3";
            conf3.PackagePath = "A Variable Name in configuration Conf3";

            Configurations pkgConfigs = p.Configurations;
            ConfigurationEnumerator myEnumerator = pkgConfigs.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Name);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace Configurations_API
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
 
            Dim conf1 As Configuration =  p.Configurations.Add() 
            conf1.ConfigurationString = "Conf1 Configuration String"
            conf1.ConfigurationType = DTSConfigurationType.EnvVariable
            conf1.Description = "Some description for Conf1 configuration"
            conf1.Name = "Conf1"
            conf1.PackagePath = "A Variable Name in configuration Conf1"
 
            Dim conf2 As Configuration =  p.Configurations.Add() 
            conf2.ConfigurationString = "Conf2 Configuration String"
            conf2.ConfigurationType = DTSConfigurationType.ConfigFile
            conf2.Description = "Some description for Conf2 configuration"
            conf2.Name = "Conf2"
            conf2.PackagePath = "A Variable Name in configuration Conf2"
 
            Dim conf3 As Configuration =  p.Configurations.Add() 
            conf3.ConfigurationString = "Conf3 Configuration String2"
            conf3.ConfigurationType = DTSConfigurationType.RegEnTry
            conf3.Description = "Conf3 description for Conf3 configuration2"
            conf3.Name = "Conf3"
            conf3.PackagePath = "A Variable Name in configuration Conf3"
 
            Dim pkgConfigs As Configurations =  p.Configurations 
            Dim myEnumerator As ConfigurationEnumerator =  pkgConfigs.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
            Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
            End While
        End Sub
    End Class
End Namespace

Sample Output:

The collection contains the following values:

[0] Conf1

[1] Conf2

[2] Conf3

Seguridad para subprocesos

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

Configurations Class
Configurations Members
Microsoft.SqlServer.Dts.Runtime Namespace