ServiceCreatorCallback 代理人
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
要求に応じてサービスのインスタンスを作成できるコールバック機構を提供します。
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 して発行されたサービスでは、要求および作成されていない場合、追加のリソースは使用されません。 コールバック関数を使用してサービスを発行するには、 の メソッドに AddService をIServiceContainer渡しますServiceCreatorCallback。
Get |
指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。 |
製品 | バージョン |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。