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 Information Services(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) |