ServiceCreatorCallback Delegasikan

Definisi

Menyediakan mekanisme panggilan balik yang dapat membuat instans layanan sesuai permintaan.

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 

Parameter

container
IServiceContainer

Kontainer layanan yang meminta pembuatan layanan.

serviceType
Type

Jenis layanan yang akan dibuat.

Tampilkan Nilai

Layanan yang ditentukan oleh serviceType, atau null jika layanan tidak dapat dibuat.

Atribut

Contoh

Contoh kode berikut menunjukkan cara menerbitkan layanan menggunakan fungsi panggilan balik.

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

Keterangan

ServiceCreatorCallback menyediakan mekanisme untuk menerbitkan layanan yang dapat Anda minta untuk dibuat saat diperlukan, bukan layanan yang segera dibuat saat perancang memuat. Anda dapat menggunakan fungsi panggilan balik jika layanan tidak penting dan mungkin tidak digunakan. Layanan yang ServiceCreatorCallback diterbitkan dengan menggunakan tidak menggunakan sumber daya tambahan sebanyak jika tidak diminta dan dibuat. Untuk menggunakan fungsi panggilan balik untuk menerbitkan layanan Anda, teruskan ServiceCreatorCallback ke AddService metode IServiceContainer.

Metode Ekstensi

GetMethodInfo(Delegate)

Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan.

Berlaku untuk

Lihat juga