ServiceCreatorCallback 代理人
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オンデマンドでサービスのインスタンスを作成できるコールバック メカニズムを提供します。
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
パラメーター
- 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) |
指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。 |