ServiceCreatorCallback Delegato
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce un meccanismo di callback che può creare un'istanza di un servizio su richiesta.
public delegate System::Object ^ ServiceCreatorCallback(IServiceContainer ^ container, Type ^ serviceType);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate object ServiceCreatorCallback(IServiceContainer container, Type serviceType);
public delegate object ServiceCreatorCallback(IServiceContainer container, Type serviceType);
[<System.Runtime.InteropServices.ComVisible(true)>]
type ServiceCreatorCallback = delegate of IServiceContainer * Type -> obj
type ServiceCreatorCallback = delegate of IServiceContainer * Type -> obj
Public Delegate Function ServiceCreatorCallback(container As IServiceContainer, serviceType As Type) As Object
Parametri
- container
- IServiceContainer
Contenitore del servizio che ha richiesto la creazione del servizio.
- serviceType
- Type
Tipo di servizio da creare.
Valore restituito
Servizio specificato da serviceTypeo null se non è stato possibile creare il servizio.
- Attributi
Esempio
Nell'esempio di codice seguente viene illustrato come pubblicare un servizio usando una funzione di callback.
// The following code shows how to publish a service using a callback function.
// Creates a service creator callback.
ServiceCreatorCallback^ callback1 =
gcnew ServiceCreatorCallback( this, &Sample::myCallBackMethod );
// Adds the service using its type and the service creator callback.
serviceContainer->AddService( myService::typeid, callback1 );
// The following code shows how to publish a service using a callback function.
// Creates a service creator callback.
ServiceCreatorCallback callback1 =
new ServiceCreatorCallback(myCallBackMethod);
// Adds the service using its type and the service creator callback.
serviceContainer.AddService(typeof(myService), callback1);
' The following code shows how to publish a service using a callback function.
' Creates a service creator callback.
Dim callback1 As New ServiceCreatorCallback _
(AddressOf myCallBackMethod)
' Adds the service using its type and the service creator.
serviceContainer.AddService(GetType(myService), callback1)
Commenti
ServiceCreatorCallback fornisce un meccanismo per pubblicare i servizi che è possibile richiedere di aver creato quando necessario, anziché il servizio creato immediatamente al caricamento della finestra di progettazione. È possibile usare una funzione di callback se il servizio non è essenziale e potrebbe non essere usato. Un servizio pubblicato tramite un ServiceCreatorCallback oggetto non usa tutte le risorse aggiuntive se non è richiesto e creato. Per usare una funzione di callback per pubblicare il servizio, passare un ServiceCreatorCallback oggetto al AddService metodo di un oggetto IServiceContainer.
Metodi di estensione
| Nome | Descrizione |
|---|---|
| GetMethodInfo(Delegate) |
Ottiene un oggetto che rappresenta il metodo rappresentato dal delegato specificato. |