ServiceCreatorCallback 代理人

定義

要求に応じてサービスのインスタンスを作成できるコールバック機構を提供します。

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 

パラメーター

container
IServiceContainer

サービスの作成を要求したサービス コンテナー。

serviceType
Type

作成するサービスの型。

戻り値

serviceType によって指定されたサービス。サービスが作成されなかった場合は null

属性

次のコード例は、コールバック関数を使用してサービスを発行する方法を示しています。

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

注釈

ServiceCreatorCallback には、デザイナーの読み込み時にすぐに作成されるサービスではなく、必要に応じて作成を要求できるサービスを発行するメカニズムが用意されています。 サービスが必須ではなく、使用できない可能性がある場合は、コールバック関数を使用できます。 を使用 ServiceCreatorCallback して発行されたサービスでは、要求および作成されていない場合、追加のリソースは使用されません。 コールバック関数を使用してサービスを発行するには、 の IServiceContainerメソッドに AddService を渡しますServiceCreatorCallback

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください