다음을 통해 공유


TaskHost.InnerObject Property

The method used to access the task instance being hosted by the TaskHost.

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

구문

‘선언
<BrowsableAttribute(False)> _
Public ReadOnly Property InnerObject As Object
[BrowsableAttribute(false)] 
public Object InnerObject { get; }
[BrowsableAttribute(false)] 
public:
virtual property Object^ InnerObject {
    Object^ get () sealed;
}
/** @property */
public final Object get_InnerObject ()
public final function get InnerObject () : Object

속성 값

The object that is contained by the TaskHost.

주의

You can retrieve the specific task instance by casting the InnerObject of the TaskHost as the task type. Then you use the task's object to access its methods and properties directly.

The following code example adds a FileSystemTask and BulkInsertTask to a package and retrieves the tasks in a loop using the InnerObject method of the TaskHost to determine the task type.

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

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package p = new Package();
            // Add a File System task to the package.
            Executable exec1 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileSystemTask1 = exec1 as TaskHost;
            // Add a Bulk Insert task to the package.
            Executable exec2 = p.Executables.Add("STOCK:BulkInsertTask");
            TaskHost thFileSystemTask2 = exec2 as TaskHost;

            // Iterate through the package Executables collection.
            Executables pExecs = p.Executables;
            foreach (Executable pExec in pExecs)
            {
                TaskHost taskHost = (TaskHost)pExec;
                Console.WriteLine("Type {0}", taskHost.InnerObject.ToString());

                if (taskHost.InnerObject is Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask)
                {
                    // Do work here.
                }
                else if (taskHost.InnerObject is Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask)
                {
                    // Do work here.
                }
                // Continue to add statements to check InnerObject, if desired.
            }
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
            ' Add a File System task to the package.
            Dim exec1 As Executable =  p.Executables.Add("STOCK:FileSystemTask") 
            Dim thFileSystemTask1 As TaskHost =  exec1 as TaskHost 
            ' Add a Bulk Insert task to the package.
            Dim exec2 As Executable =  p.Executables.Add("STOCK:BulkInsertTask") 
            Dim thFileSystemTask2 As TaskHost =  exec2 as TaskHost 
 
            ' Iterate through the package Executables collection.
            Dim pExecs As Executables =  p.Executables 
            Dim pExec As Executable
            For Each pExec In pExecs
                Dim taskHost As TaskHost = CType(pExec, TaskHost)
                Console.WriteLine("Type {0}", taskHost.InnerObject.ToString())
 
                If TypeOf taskHost.InnerObject Is Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask Then
                    ' Do work here.
                Else If TypeOf taskHost.InnerObject Is Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask Then 
                    ' Do work here.
                End If
                ' Continue to add statements to check InnerObject, if desired.
            Next
        End Sub
    End Class
End Namespace

Sample Output:

Type Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask

Type Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask

스레드 보안

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.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

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