Compartir a través de


Configurations.Item[Object] Propiedad

Definición

Devuelve un objeto Configuration de la colección.

public:
 property Microsoft::SqlServer::Dts::Runtime::Configuration ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::Configuration ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.Configuration this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.Configuration
Default Public ReadOnly Property Item(index As Object) As Configuration

Parámetros

index
Object

El nombre, la descripción, el identificador o el índice del objeto Configuration que se va a devolver.

Valor de propiedad

Un objeto Configuration.

Ejemplos

En el ejemplo de código siguiente se usa el Contains método para ver si la sintaxis del elemento está disponible. Si truees , el ejemplo de código usa la sintaxis de elemento de p.Configurations[0].Name para obtener el nombre de la configuración ubicada en la primera posición de la colección, posición de índice 0.

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";  

            // Use Contains to see if item syntax is available.  
            Boolean configContains = p.Configurations.Contains("Conf3");  

            if (configContains)  
            {  
                // Use the item syntax of Configurations[x].  
                String myName = p.Configurations[0].Name;  
                Console.WriteLine("Name of configuration at position 0 is {0}", myName);  
            }  
            else  
            {  
                Console.WriteLine("Contains returned {0}", configContains);  
            }  

            Console.WriteLine();  
        }  
    }  
}  
'Error: Converting Methods, Functions and Constructors   
'Error: Converting If-Else-End If Blocks   

Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace Configurations_API  
    Class Program  
        static void Main(string() args)  
        {  
            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"  

            ' Use Contains to see if item syntax is available.  
            Dim configContains As Boolean =  p.Configurations.Contains("Conf3")   

            if (configContains)  
            {  
                ' Use the item syntax of Configurations[x].  
                Dim myName As String = p.Configurations(0).Name   
                Console.WriteLine("Name of configuration at position 0 is {0}", myName)  
            }  
            else  
            {  
                Console.WriteLine("Contains returned {0}", configContains)  
            }  

            Console.WriteLine()  
        }  
    End Class  
End Namespace  

Salida del ejemplo:

El nombre de la configuración en la posición 0 es Conf1

Comentarios

Si la llamada al Contains método devuelve true, puede tener acceso al elemento especificado en la colección mediante la sintaxis Configurations[index]. Sin embargo, si el Contains método devuelve false, esta propiedad produce una excepción. En C#, esta propiedad es el indizador para la clase Configurations.

Se aplica a