你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

FabricRuntime.RegisterServiceType(String, Type) 方法

定义

将指定的 serviceTypeName 与实现它的实际托管类型相关联。

public void RegisterServiceType (string serviceTypeName, Type serviceTypeImplementation);
member this.RegisterServiceType : string * Type -> unit
Public Sub RegisterServiceType (serviceTypeName As String, serviceTypeImplementation As Type)

参数

serviceTypeName
String

服务类型的类型名称 (为字符串) 。 这应与清单和/或 CreateService 命令中指定的服务组类型的类型匹配。

serviceTypeImplementation
Type

实现指定 serviceTypeName的限定服务类型。

注解

请注意,此服务类型注册机制不需要在注册时提供自定义 IStatelessServiceFactoryIStatefulServiceFactory 。 Service Fabric 将在运行时生成一个并自动利用它。 如果需要工厂的自定义实现,可以实现 IStatelessServiceFactoryIStatefulServiceFactory ,然后通过相应的工厂注册方法提供这些 (RegisterStatelessServiceFactoryAsync(String, IStatelessServiceFactory, TimeSpan, CancellationToken)RegisterStatefulServiceFactoryAsync(String, IStatefulServiceFactory, TimeSpan, CancellationToken))

适用于