WorkflowView.GetService(Type) Méthode

Définition

Obtient l'objet service du type spécifié (si disponible).

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

Paramètres

serviceType
Type

Type du service à récupérer.

Retours

Object

Si le serviceType est typeof(CommandID), GetService retourne alors un CommandIDspécifique ; sinon, GetService retourne un Object qui implémente le service demandé ou une référence Null (Nothing en Visual Basic) si le service ne peut pas être résolu.

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

GetService retourne un Object qui implémente le service demandé ou une référence Null (Nothing) si le service ne peut pas être résolu.

S’applique à