ServiceCreatorCallback Delegado

Definición

Proporciona un mecanismo de devolución de llamada que puede crear una instancia de un servicio a petición.Provides a callback mechanism that can create an instance of a service on demand.

public delegate System::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 

Parámetros

container
IServiceContainer

Contenedor de servicios que solicitó la creación del servicio.The service container that requested the creation of the service.

serviceType
Type

Tipo de servicio que se va a crear.The type of service to create.

Valor devuelto

Object

Servicio especificado por serviceType o null si no se ha podido crear el servicio.The service specified by serviceType, or null if the service could not be created.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo publicar un servicio usando una función de devolución de llamada.The following code example shows how to publish a service using a callback function.

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

Comentarios

ServiceCreatorCallback proporciona un mecanismo para publicar servicios que se pueden solicitar que se creen cuando sea necesario, en lugar de que el servicio se cree inmediatamente cuando se cargue el diseñador.ServiceCreatorCallback provides a mechanism to publish services that you can request to have created when needed, rather than the service being created immediately when the designer loads. Puede usar una función de devolución de llamada si el servicio no es esencial y no se puede usar.You can use a callback function if the service is not essential and may not be used. Un servicio publicado mediante un no ServiceCreatorCallback usa tantos recursos adicionales si no se solicita y se crea.A service published by using a ServiceCreatorCallback does not use as many additional resources if it is not requested and created. Para usar una función de devolución de llamada para publicar el servicio, pase un ServiceCreatorCallback al AddService método de IServiceContainer .To use a callback function to publish your service, pass a ServiceCreatorCallback to the AddService method of an IServiceContainer.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a

Consulte también