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)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보