WorkflowView.GetService(Type) Metodo

Definizione

Ottiene l'oggetto servizio del tipo specificato, se disponibile.

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

Parametri

serviceType
Type

Oggetto Type del servizio da recuperare.

Restituisce

Se il parametro serviceType è typeof(CommandID), GetService restituisce una specifica classe CommandID. In caso contrario GetService restituisce una classe Object che implementa il servizio richiesto oppure un riferimento null (Nothing in Visual Basic) se il servizio non può essere risolto.

Esempio

Nell'esempio seguente viene utilizzato il metodo GetService dell'oggetto WorkflowView per restituire un'interfaccia ISelectionService. Se il servizio esiste, viene chiamato il metodo EnsureVisible passando l'attività attualmente selezionata mediante la proprietà PrimarySelection dell'oggetto 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

Commenti

GetService restituisce una classe Object che implementa il servizio richiesto oppure un riferimento null (Nothing) se il servizio non può essere risolto.

Si applica a