ServiceCreatorCallback Delegat

Definicja

Udostępnia mechanizm wywołania zwrotnego, który może utworzyć wystąpienie usługi na żądanie.

public delegate System::Object ^ ServiceCreatorCallback(IServiceContainer ^ container, Type ^ serviceType);
public delegate object ServiceCreatorCallback(IServiceContainer container, Type serviceType);
public delegate object? ServiceCreatorCallback(IServiceContainer container, Type serviceType);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate object ServiceCreatorCallback(IServiceContainer container, Type serviceType);
type ServiceCreatorCallback = delegate of IServiceContainer * Type -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
type ServiceCreatorCallback = delegate of IServiceContainer * Type -> obj
Public Delegate Function ServiceCreatorCallback(container As IServiceContainer, serviceType As Type) As Object 

Parametry

container
IServiceContainer

Kontener usługi, który zażądał utworzenia usługi.

serviceType
Type

Typ usługi do utworzenia.

Wartość zwracana

Usługa określona przez serviceTypeprogram lub null jeśli nie można utworzyć usługi.

Atrybuty

Przykłady

Poniższy przykład kodu pokazuje, jak opublikować usługę przy użyciu funkcji wywołania zwrotnego.

// 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)

Uwagi

ServiceCreatorCallback Zapewnia mechanizm publikowania usług, które można zażądać utworzenia w razie potrzeby, a nie usługi tworzonej natychmiast po załadowaniu projektanta. Możesz użyć funkcji wywołania zwrotnego, jeśli usługa nie jest niezbędna i może nie być używana. Usługa opublikowana przy użyciu elementu ServiceCreatorCallback nie używa tyle dodatkowych zasobów, jeśli nie jest żądana i utworzona. Aby użyć funkcji wywołania zwrotnego do opublikowania usługi, przekaż element ServiceCreatorCallback do AddService metody .IServiceContainer

Metody rozszerzania

GetMethodInfo(Delegate)

Pobiera obiekt reprezentujący metodę reprezentowaną przez określonego delegata.

Dotyczy

Zobacz też