WorkflowRuntime.GetService WorkflowRuntime.GetService WorkflowRuntime.GetService WorkflowRuntime.GetService Method

정의

오버로드

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

워크플로 런타임 엔진에서 지정된 Type의 서비스를 검색합니다.Retrieves a service of the specified Type from the workflow run-time engine.

GetService<T>() GetService<T>() GetService<T>() GetService<T>()

워크플로 런타임 엔진에서 지정된 제네릭 형식의 서비스를 검색합니다.Retrieves a service of the specified generic type from the workflow run-time engine.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

워크플로 런타임 엔진에서 지정된 Type의 서비스를 검색합니다.Retrieves a service of the specified Type from the workflow run-time engine.

public:
 virtual System::Object ^ GetService(Type ^ serviceType);
public object GetService (Type serviceType);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Public Function GetService (serviceType As Type) As Object

매개 변수

serviceType
Type Type Type Type

검색할 서비스의 Type입니다.The Type of the service to retrieve.

반환

지정된 Type의 서비스입니다.The service of the specified Type.

구현

예외

serviceType이 null 참조(Visual Basic의 경우 Nothing)인 경우serviceType is a null reference (Nothing in Visual Basic).

serviceType 형식의 서비스가 여러 개 있는 경우More than one service of type serviceType was found.

설명

지정된 GetService에 대한 서비스가 여러 개 있으면 InvalidOperationException에서 Type을 throw합니다.GetService throws an InvalidOperationException if more than one service exists for the specified Type. 따라서 GetAllServices에 지정된 형식의 서비스가 여러 개 있을 수 있는 경우 WorkflowRuntime의 오버로드된 메서드 중 하나를 사용해야 합니다.Therefore, you should use one of the overloaded methods of GetAllServices if it is possible that multiple services of the specified type are present in the WorkflowRuntime. 예를 들어 워크플로 런타임 엔진에는 여러 개의 추적 서비스가 있을 수 있습니다.For example, the workflow run-time engine may have multiple tracking services. TrackingService 기본 클래스를 지정하여 추적 서비스를 요청하면 예외가 throw될 수 있습니다.If you request a tracking service by specifying the TrackingService base class, it is possible that an exception will be thrown.

GetService<T>() GetService<T>() GetService<T>() GetService<T>()

워크플로 런타임 엔진에서 지정된 제네릭 형식의 서비스를 검색합니다.Retrieves a service of the specified generic type from the workflow run-time engine.

public:
generic <typename T>
 T GetService();
public T GetService<T> ();
member this.GetService : unit -> 'T
Public Function GetService(Of T) () As T

형식 매개 변수

T

서비스 유형입니다.The service type.

반환

T T T T

지정된 제네릭 형식의 단일 서비스입니다.A single service of the specified generic type.

예외

제네릭 형식의 서비스가 여러 개 있는 경우More than one service of the generic type was found.

예제

다음 예제에서는 WorkflowRuntime 개체에서 단일 서비스, 이 경우 ManualWorkflowSchedulerService 유형의 서비스를 검색하는 방법을 보여 줍니다.The following example demonstrates how to retrieve a single service from a WorkflowRuntime object; in this case, a service of type ManualWorkflowSchedulerService. 이 예제에서는 합니다 Workflow Threading 샘플합니다.This example is from the Workflow Threading Sample.

protected override CompositeActivity OnCreateNewBranch()
{
    return new ParallelIfBranch();
}

private void OnAddBranch(object sender, EventArgs e)
{
    CompositeActivity activity1 = this.OnCreateNewBranch();
    CompositeActivity activity2 = base.Activity as CompositeActivity;

    if ((activity2 != null) && (activity1 != null))
    {
        int num1 = this.ContainedDesigners.Count;
        Activity[] activityArray1 = new Activity[] { activity1 };

        if (CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
            new List<Activity>(activityArray1).AsReadOnly()))
        {
            CompositeActivityDesigner.InsertActivities(this,
                new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
                new List<Activity>(activityArray1).AsReadOnly(),
                string.Format("Adding branch {0}", activity1.GetType().Name));

            if ((this.ContainedDesigners.Count > num1) && (this.ContainedDesigners.Count > 0))
            {
                this.ContainedDesigners[this.ContainedDesigners.Count - 1].EnsureVisible();
            }
        }
    }
}
Protected Overrides Function OnCreateNewBranch() As CompositeActivity
    Return New ParallelIfBranch()
End Function

Private Sub OnAddBranch(ByVal sender As Object, ByVal e As EventArgs)
    Dim activity1 As CompositeActivity = Me.OnCreateNewBranch()
    Dim activity2 As CompositeActivity = CType(MyBase.Activity, CompositeActivity)

    If (activity2 IsNot Nothing) And (activity1 IsNot Nothing) Then

        Dim num1 As Integer = Me.ContainedDesigners.Count
        Dim activityArray1() As Activity = {activity1}

        If (CanInsertActivities(New ConnectorHitTestInfo(Me, HitTestLocations.Designer, activity2.Activities.Count), _
            New List(Of Activity)(activityArray1).AsReadOnly())) Then

            CompositeActivityDesigner.InsertActivities(Me, _
                New ConnectorHitTestInfo(Me, HitTestLocations.Designer, activity2.Activities.Count), _
                New List(Of Activity)(activityArray1).AsReadOnly(), _
                String.Format("Adding branch 0}", activity1.GetType().Name))

            If (Me.ContainedDesigners.Count > num1) And (Me.ContainedDesigners.Count > 0) Then
                Me.ContainedDesigners(Me.ContainedDesigners.Count - 1).EnsureVisible()
            End If
        End If
    End If
End Sub

설명

지정된 제네릭 형식에 대한 서비스가 여러 개 있으면 GetService에서 InvalidOperationException을 throw합니다.GetService throws an InvalidOperationException if more than one service exists for the specified generic type. 따라서 GetAllServices에 해당 제네릭 형식의 서비스가 여러 개 있을 수 있는 경우 WorkflowRuntime의 오버로드된 메서드 중 하나를 사용해야 합니다.Therefore, you should use one of the overloaded methods of GetAllServices if it is possible that multiple services of the generic type are present in the WorkflowRuntime. 예를 들어 워크플로 런타임 엔진에는 여러 개의 추적 서비스가 있을 수 있습니다.For example, the workflow run-time engine may have multiple tracking services. TrackingService 기본 클래스를 지정하여 추적 서비스를 요청하면 예외가 throw될 수 있습니다.If you request a tracking service by specifying the TrackingService base class, it is possible that an exception will be thrown.

적용 대상