我正在尝试通过单个 WCF 实现多个服务契约(Contract)。
我正在尝试运行此代码:
return new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(
Component.For<IServiceBehavior>().Instance(metadata),
Component.For<IServiceBehavior>().Instance(debug),
Component
.For<IBlogService>()
.ImplementedBy<DefaultBlogService>()
.Named("blogService")
.LifeStyle.Transient
.ActAs(new DefaultServiceModel().Hosted()
.AddEndpoints(
WcfEndpoint.BoundTo(new BasicHttpBinding()))),
Component
.For<IBlogServiceAlternate>()
.ImplementedBy<AlternateBlogService>()
.Named("blogService")
.LifeStyle.Transient
.ActAs(new DefaultServiceModel().Hosted()
.AddEndpoints(
WcfEndpoint.BoundTo(new BasicHttpBinding()))),
Component
.For<ILogger>()
.ImplementedBy<DefaultLogger>()
.LifeStyle.Transient
);
但它告诉我“blogservice”已经注册。 我正在加载两个不同的接口(interface),它们是通过不同的类实现的。 我陷入了这一点。
最佳答案
直接写
Component.For<IFirst,ISecond>(). /*whatever else you need*/
关于wcf - CaSTLe Windsor 组件在单个服务上注册多个接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3592188/