WorkflowView.GetService(Type) Método

Definición

Obtiene el objeto de servicio del tipo especificado, si está 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

Parámetros

serviceType
Type

Type del servicio que se va a recuperar.

Devoluciones

Si serviceType es typeof(CommandID) a continuación GetService devuelve un CommandIDespecífico; de lo contrario, GetService devuelve un Object que implementa el servicio solicitado o una referencia nula (Nothing en Visual Basic) si no se puede resolver el servicio.

Ejemplos

El siguiente ejemplo utiliza el método GetService del objeto WorkflowView para devolver una interfaz ISelectionService. Si el servicio existe, EnsureVisible se llama pasando la actividad actualmente seleccionada mediante la propiedad PrimarySelection del objeto 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

Comentarios

GetService devuelve un Object que implementa el servicio solicitado o una referencia nula (Nothing) si no se puede resolver el servicio.

Se aplica a