WorkflowView.IServiceProvider.GetService(Type) Méthode

Définition

Obtient le service du type spécifié (si disponible).

 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

Paramètres

serviceType
Type

Type du service à récupérer.

Retours

Object

Object qui implémente le service demandé, ou référence Null (Nothing en Visual Basic) si le service ne peut pas être résolu.

Implémente

Exemples

Les exemples suivants utilisent la méthode GetService de l'objet WorkflowView pour retourner une interface ISelectionService. Si le service existe, la méthode EnsureVisible est appelée en passant l'activité actuellement sélectionnée à l'aide de la propriété PrimarySelection de l'objet 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

Remarques

Si le serviceType est CommandID, cette méthode retourne un CommandID spécifique. Pour tout autre Type, GetService retournera un objet qui implémente le service demandé, ou une référence Null (Nothing) si le service ne peut pas être résolu.

S’applique à