다음을 통해 공유


Executables.Item[Object] 속성

정의

컬렉션에서 Executable 개체를 가져옵니다.

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

매개 변수

index
Object

반환할 Executable 개체의 인덱스입니다.

속성 값

컬렉션의 Executable 개체입니다.

예제

다음 예제는 Remove에 있는 샘플을 수정한 것입니다. 항목 구문을 사용하여 실행 파일을 제거합니다.

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

namespace Executables_API  
{  
        class Program  
        {  
                static void Main(string[] args)  
                {  
                    Executable exec = pkg.Executables.Add("STOCK:BulkInsertTask");  
                    TaskHost myTask = exec as TaskHost;  
                    BulkInsertTask myBI = myTask.InnerObject as BulkInsertTask;  
                    myBI.DebugMode = false;  
                    myBI.CheckConstraints = false;  
                    myBI.KeepIdentity = true;  

                    // Obtain the collection.  
                    Executables pgkExecs = pkg.Executables;  
                    // Show the number of executables in the collection.  
                    Console.WriteLine("The first package contains {0} executables", pgkExecs.Count);  

                    // It is a requirement to Remove the task from the  
                    // existing package before adding it to the new package.  
                    // Remove the exectuable using the Executables[x] item syntax.   
                    DtsContainer c = (DtsContainer)pkg.Executables[0];  
                    pkg.Executables.Remove(c);  

                    // Show the number of executables in the collection afterwards.  
                    Console.WriteLine("The first package now contains {0} executables", pgkExecs.Count);  

                    Package pkg2 = new Package();  
                    Executables p2Execs = pkg2.Executables;  
                    // Show the number of executables in the second collection.  
                    Console.WriteLine("The second package initially contains {0} executables", p2Execs.Count);  
                    // Join the task from pkg to pkg2.  
                    pkg2.Executables.Join(myTask);  
                    // Show the number of executables in the second collection after Join.  
                    Console.WriteLine("The second package now contains {0} executables", p2Execs.Count);  

        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask  

Namespace Executables_API  
        Class Program  
                Shared  Sub Main(ByVal args() As String)  
                    Dim exec As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask")   
                    Dim myTask As TaskHost =  exec as TaskHost   
                    Dim myBI As BulkInsertTask =  myTask.InnerObject as BulkInsertTask   
                    myBI.DebugMode = False  
                    myBI.CheckConstraints = False  
                    myBI.KeepIdentity = True  

                    ' Obtain the collection.  
                    Dim pgkExecs As Executables =  pkg.Executables   
                    ' Show the number of executables in the collection.  
                    Console.WriteLine("The first package contains {0} executables", pgkExecs.Count)  

                    ' It is a requirement to Remove the task from the  
                    ' existing package before adding it to the new package.  
                    ' Remove the exectuable using the Executables[x] item syntax.   
                    Dim c As DtsContainer = CType(pkg.Executables(0), DtsContainer)  
                    pkg.Executables.Remove(c)  

                    ' Show the number of executables in the collection afterwards.  
                    Console.WriteLine("The first package now contains {0} executables", pgkExecs.Count)  

                    Dim pkg2 As Package =  New Package()   
                    Dim p2Execs As Executables =  pkg2.Executables   
                    ' Show the number of executables in the second collection.  
                    Console.WriteLine("The second package initially contains {0} executables", p2Execs.Count)  
                    ' Join the task from pkg to pkg2.  
                    pkg2.Executables.Join(myTask)  
                    ' Show the number of executables in the second collection after Join.  
                    Console.WriteLine("The second package now contains {0} executables", p2Execs.Count)  

                End Sub  
        End Class  
End Namespace  

샘플 출력:

The first package contains 1 executables

The first package now contains 0 executables

The second package initially contains 0 executables

The second package now contains 1 executables

설명

메서드 호출이 Contains 반환 true되는 경우 구문을 Executables[index]사용하여 컬렉션에서 지정된 요소에 액세스할 수 있습니다. 반환false되는 Contains 경우 이 속성은 예외를 throw합니다. C#에서 이 속성은 Executables 클래스의 인덱서입니다.

적용 대상