WorkflowView.GetService(Type) 메서드

정의

가능한 경우, 지정된 형식의 서비스 개체를 가져옵니다.

protected:
 override System::Object ^ GetService(Type ^ serviceType);
protected override object GetService (Type serviceType);
override this.GetService : Type -> obj
Protected Overrides Function GetService (serviceType As Type) As Object

매개 변수

serviceType
Type

검색할 서비스의 Type입니다.

반환

serviceTypetypeof(CommandID)일 경우 GetService가 관련 CommandID를 반환합니다. 그렇지 않을 경우 GetService는 요청된 서비스를 구현하는 Object를 반환하거나 서비스를 확인할 수 없는 경우 null 참조(Visual Basic에서는 Nothing)를 반환합니다.

예제

다음 코드 예제에서는 GetService 개체의 WorkflowView 메서드를 사용하여 ISelectionService 인터페이스를 반환합니다. 서비스가 존재하는 경우 EnsureVisible 개체의 PrimarySelection 속성을 사용하여 ISelectionService을 호출해 현재 선택된 활동을 전달합니다.

public void FindSelection()
{
    ISelectionService selectionService;
    selectionService = ((IServiceProvider)this.workflowView).GetService(typeof(ISelectionService))
        as ISelectionService;

    if (selectionService != null)
        this.workflowView.EnsureVisible(selectionService.PrimarySelection);
}
Public Sub FindSelection()
    Dim selectionService As ISelectionService
    selectionService = CType(CType(Me.workflowView, IServiceProvider).GetService(GetType(ISelectionService)), ISelectionService)

    If selectionService IsNot Nothing Then
        Me.workflowView.EnsureVisible(selectionService.PrimarySelection)
    End If
End Sub

설명

GetService는 요청된 서비스를 구현하는 Object를 반환하거나 서비스를 확인할 수 없는 경우 null 참조(Nothing)를 반환합니다.

적용 대상