ServiceCreatorCallback Temsilci

Tanım

İsteğe bağlı olarak bir hizmetin örneğini oluşturabilen bir geri çağırma mekanizması sağlar.

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 

Parametreler

container
IServiceContainer

Hizmetin oluşturulmasını isteyen hizmet kapsayıcısı.

serviceType
Type

Oluşturulacak hizmet türü.

Dönüş Değeri

tarafından serviceTypebelirtilen hizmet veya null hizmet oluşturulamadıysa.

Öznitelikler

Örnekler

Aşağıdaki kod örneğinde geri çağırma işlevi kullanarak bir hizmetin nasıl yayımlanması gösterilmektedir.

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

Açıklamalar

ServiceCreatorCallback , tasarımcı yüklendiğinde hemen oluşturulan hizmet yerine, gerektiğinde oluşturulmasını isteyebileceğiniz hizmetleri yayımlamak için bir mekanizma sağlar. Hizmet gerekli değilse ve kullanılmıyorsa geri çağırma işlevini kullanabilirsiniz. kullanılarak yayımlanan bir ServiceCreatorCallback hizmet, istenmemesi ve oluşturulmaması durumunda o kadar fazla ek kaynak kullanmaz. Hizmetinizi yayımlamak için bir geri çağırma işlevi kullanmak için yöntemine AddService bir ServiceCreatorCallbackIServiceContainergeçirin.

Uzantı Metotları

Name Description
GetMethodInfo(Delegate)

Belirtilen temsilci tarafından temsil edilen yöntemi temsil eden bir nesnesi alır.

Şunlara uygulanır

Ayrıca bkz.