다음을 통해 공유


Configurations.Item 속성

Returns a Configuration object from the collection.

네임스페이스:  Microsoft.SqlServer.Dts.Runtime
어셈블리:  Microsoft.SqlServer.ManagedDTS(Microsoft.SqlServer.ManagedDTS.dll)

구문

‘선언
Public ReadOnly Default Property Item ( _
    index As Object _
) As Configuration 
    Get
‘사용 방법
Dim instance As Configurations 
Dim index As Object 
Dim value As Configuration 

value = instance(index)
public Configuration this[
    Object index
] { get; }
public:
property Configuration^ default[Object^ index] {
    Configuration^ get (Object^ index);
}
member Item : Configuration
Jscript는 인덱싱된 속성의 사용을 지원하지만 새로운 인덱싱된 속성 선언은 지원하지 않습니다.

매개 변수

속성 값

유형: Microsoft.SqlServer.Dts.Runtime.Configuration
A Configuration object.

주의

If the call to the Contains method returns true, you can access the specified element in the collection by using the syntax Configurations[index]. However, if the Contains method returns false, this property throws an exception. In C#, this property is the indexer for the Configurations class.

The following code example uses the Contains method to see if item syntax is available. If true, the code example uses the item syntax of p.Configurations[0].Name to get the name of the configuration located in the first position of the collection, index position 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

Sample Output:

Name of configuration at position 0 is Conf1

참고 항목

참조

Configurations 클래스

Microsoft.SqlServer.Dts.Runtime 네임스페이스