ServiceManager.Publish 方法

定义

发布给定的服务类型,但不声明实例。Publishes the given service type, but does not declare an instance. 在请求服务时,将调用 Publish 服务回调来创建实例。When the service is requested, the Publish service callback will be invoked to create the instance. 只会调用该回调一次。The callback is invoked only once. 之后,会将它返回的实例放入缓存。After that, the instance it returned is cached.

重载

Publish(Type, Object)

发布给定的服务。Publishes the given service. 服务发布之后,服务实例将保留在服务管理器中,直至释放编辑上下文为止。After it is published, the service instance remains in the service manager until the editing context is disposed of.

Publish(Type, PublishServiceCallback)

发布指定的服务类型,但不声明实例。Publishes the specified service type, but does not declare an instance. 在请求服务时,将调用 Publish 服务回调来创建实例。When the service is requested, the Publish service callback will be invoked to create the instance. 只会调用该回调一次。The callback is invoked only once. 之后,会将它返回的实例放入缓存。After that, the instance it returned is cached.

Publish<TServiceType>(PublishServiceCallback<TServiceType>)

发布给定的服务类型,但尚未声明实例。Publishes the given service type, but does not declare an instance yet. 当该服务被要求时,将调用 PublishServiceCallback 以创建该服务的实例。When the service is requested, the PublishServiceCallback will be invoked to create the instance. 只会调用该回调一次。The callback is invoked only once. 之后,会将它返回的实例放入缓存。After that, the instance it returned is cached.

Publish<TServiceType>(TServiceType)

发布给定的服务。Publishes the given service. 服务发布之后,服务实例将保留在服务管理器中,直至释放编辑上下文为止。After it is published, the service instance remains in the service manager until the editing context is disposed of.

Publish(Type, Object)

发布给定的服务。Publishes the given service. 服务发布之后,服务实例将保留在服务管理器中,直至释放编辑上下文为止。After it is published, the service instance remains in the service manager until the editing context is disposed of.

public:
 abstract void Publish(Type ^ serviceType, System::Object ^ serviceInstance);
public abstract void Publish (Type serviceType, object serviceInstance);
abstract member Publish : Type * obj -> unit
Public MustOverride Sub Publish (serviceType As Type, serviceInstance As Object)

参数

serviceType
Type

要发布的服务的类型。The type of service to publish.

serviceInstance
Object

服务的实例。An instance of the service.

例外

serviceTypeserviceInstancenullserviceType or serviceInstance is null.

serviceInstance 未派生自或实现 serviceType,或者 serviceType 已发布。serviceInstance does not derive from or implement serviceType, or serviceType has already been published.

适用于

Publish(Type, PublishServiceCallback)

发布指定的服务类型,但不声明实例。Publishes the specified service type, but does not declare an instance. 在请求服务时,将调用 Publish 服务回调来创建实例。When the service is requested, the Publish service callback will be invoked to create the instance. 只会调用该回调一次。The callback is invoked only once. 之后,会将它返回的实例放入缓存。After that, the instance it returned is cached.

public:
 abstract void Publish(Type ^ serviceType, System::Activities::Presentation::PublishServiceCallback ^ callback);
public abstract void Publish (Type serviceType, System.Activities.Presentation.PublishServiceCallback callback);
abstract member Publish : Type * System.Activities.Presentation.PublishServiceCallback -> unit
Public MustOverride Sub Publish (serviceType As Type, callback As PublishServiceCallback)

参数

serviceType
Type

要发布的服务的类型。The type of service to publish.

callback
PublishServiceCallback

将在需要服务的实例时调用回调。A callback that will be invoked when an instance of the service is needed.

例外

serviceTypecallbacknullserviceType or callback is null.

serviceType 已发布。serviceType has already been published.

适用于

Publish<TServiceType>(PublishServiceCallback<TServiceType>)

发布给定的服务类型,但尚未声明实例。Publishes the given service type, but does not declare an instance yet. 当该服务被要求时,将调用 PublishServiceCallback 以创建该服务的实例。When the service is requested, the PublishServiceCallback will be invoked to create the instance. 只会调用该回调一次。The callback is invoked only once. 之后,会将它返回的实例放入缓存。After that, the instance it returned is cached.

public:
generic <typename TServiceType>
 void Publish(System::Activities::Presentation::PublishServiceCallback<TServiceType> ^ callback);
public void Publish<TServiceType> (System.Activities.Presentation.PublishServiceCallback<TServiceType> callback);
member this.Publish : System.Activities.Presentation.PublishServiceCallback<'ServiceType> -> unit
Public Sub Publish(Of TServiceType) (callback As PublishServiceCallback(Of TServiceType))

类型参数

TServiceType

要发布的服务的类型。The type of the service to publish.

参数

callback
PublishServiceCallback<TServiceType>

将在需要服务的实例时调用回调。A callback that will be invoked when an instance of the service is needed.

例外

callbacknullcallback is null.

适用于

Publish<TServiceType>(TServiceType)

发布给定的服务。Publishes the given service. 服务发布之后,服务实例将保留在服务管理器中,直至释放编辑上下文为止。After it is published, the service instance remains in the service manager until the editing context is disposed of.

public:
generic <typename TServiceType>
 void Publish(TServiceType serviceInstance);
public void Publish<TServiceType> (TServiceType serviceInstance);
member this.Publish : 'ServiceType -> unit
Public Sub Publish(Of TServiceType) (serviceInstance As TServiceType)

类型参数

TServiceType

要发布的服务的类型。The type of the service to publish.

参数

serviceInstance
TServiceType

服务的实例。An instance of the service.

例外

serviceInstancenullserviceInstance is null.

适用于