Dependency injection 如何在castle windsor wcf设施注册我的所有服务
基本上我可以注册一个这样的服务Dependency injection 如何在castle windsor wcf设施注册我的所有服务,dependency-injection,castle-windsor,wcffacility,Dependency Injection,Castle Windsor,Wcffacility,基本上我可以注册一个这样的服务 Container.Register(Component.For<IMyService>() .AsWcfClient(new DefaultClientModel() { Endpoint = WcfEndpoint .BoundTo(new NetNamedPipeBindin
Container.Register(Component.For<IMyService>()
.AsWcfClient(new DefaultClientModel() {
Endpoint = WcfEndpoint
.BoundTo(new NetNamedPipeBinding())
.At("net.pipe://localhost/MyService") })
.LifeStyle.PerWebRequest);
如何将所有服务注册为wcf客户端?使用Windsor 3.0,您只需使用类型而不是所有类型,以便它注册服务接口并为您生成客户端动态代理,如下所示:
Container
.Register(
Types
.FromAssemblyNamed("My.Server.MyContracts")
.Pick()
.If(x => x.Name.EndsWith("Service"))
.Configure(
configurer => configurer.Named(configurer.Implementation.Name)
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint
.BoundTo(new NetNamedPipeBinding())
.At(string.Format(
"net.pipe://localhost/{0}",
configurer.Name.Substring(1)))
}))
.LifestylePerWebRequest());
Container
.Register(
Types
.FromAssemblyNamed("My.Server.MyContracts")
.Pick()
.If(x => x.Name.EndsWith("Service"))
.Configure(
configurer => configurer.Named(configurer.Implementation.Name)
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint
.BoundTo(new NetNamedPipeBinding())
.At(string.Format(
"net.pipe://localhost/{0}",
configurer.Name.Substring(1)))
}))
.LifestylePerWebRequest());