다음을 통해 공유


WorkflowView.IServiceProvider.GetService(Type) 메서드

정의

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

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

매개 변수

serviceType
Type

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

반환

Object

요청된 서비스를 구현하는 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

설명

serviceTypeCommandID일 경우 이 메서드는 지정된 CommandID를 반환합니다. 다른 Type의 경우 GetService는 요청된 서비스를 구현하는 개체를 반환하거나 서비스를 확인할 수 없는 경우 null 참조(Nothing)를 반환합니다.

적용 대상