ServiceHostFactory 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在托管宿主环境中提供 ServiceHost 的实例的工厂,在此环境中为响应传入消息而动态创建宿主实例。
public ref class ServiceHostFactory : System::ServiceModel::Activation::ServiceHostFactoryBase
public class ServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactoryBase
type ServiceHostFactory = class
inherit ServiceHostFactoryBase
Public Class ServiceHostFactory
Inherits ServiceHostFactoryBase
- 继承
- 派生
示例
下面的示例演示如何使用 ServiceHostFactory 类:
public class DerivedFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
{
return new DerivedHost( t, baseAddresses );
}
//Then in the CreateServiceHost method, we can do all of the
//things that we can do in a self-hosted case:
public override ServiceHostBase CreateServiceHost
(string service, Uri[] baseAddresses)
{
// The service parameter is ignored here because we know our service.
ServiceHost serviceHost = new ServiceHost(typeof(HelloService),
baseAddresses);
return serviceHost;
}
}
Public Class DerivedFactory
Inherits ServiceHostFactory
Protected Overrides Overloads Function CreateServiceHost(ByVal t As Type, ByVal baseAddresses() As Uri) As ServiceHost
Return New DerivedHost(t, baseAddresses)
End Function
'Then in the CreateServiceHost method, we can do all of the
'things that we can do in a self-hosted case:
Public Overrides Overloads Function CreateServiceHost(ByVal service As String, ByVal baseAddresses() As Uri) As ServiceHostBase
' The service parameter is ignored here because we know our service.
Dim serviceHost As New ServiceHost(GetType(HelloService), baseAddresses)
Return serviceHost
End Function
End Class
注解
支持动态激活的托管宿主环境包括 Internet 信息服务 (IIS) 和 Windows 进程激活服务 (WAS)。
如果已实现 ServiceHost 的自定义派生,还应考虑实现派生自 ServiceHostFactory 类的工厂。
如果已实现 ServiceHostBase 的自定义派生,还应考虑实现可直接从 ServiceHostFactoryBase 派生工厂的工厂。
构造函数
ServiceHostFactory() |
初始化 ServiceHostFactory 类的新实例。 |
方法
CreateServiceHost(String, Uri[]) |
创建具有特定基址的 ServiceHost,并使用指定数据对其进行初始化。 |
CreateServiceHost(Type, Uri[]) |
为具有特定基址的指定类型的服务创建 ServiceHost。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |