![](/img/trans.png)
[英]In Castle Windsor, how to register ONE of many implementations of generic interface for ALL found implementations of generic type?
[英]How to register all WCF service implementations in Castle Windsor
首先,对可能重复的问题感到抱歉,但我是新手,同时对温莎城堡项目感到兴奋。 我已经重构了Web API服务,以利用DI和UnitTesting的优势。 项目结构: API(Web Api) > WcfServiceWrapper(图书馆项目) >>( IAuthorizationService, IBussinesProcessService, IClientService
...(服务参考))。 所有服务参考在配置文件中都有其配置。
在WcfServiceWrapper中,我正在使用ex .:
using(IAuthorizationService serviceClient = new AuthorizationServiceClient()){
}
现在,对于Castle,我希望所有引用的服务( IAuthorizationService, IBussinesProcessService, IClientService ...
)都使用其实现( AuthorizationServiceClient, BussinesProcessServiceClient, ClientServiceClient ...
)
城堡配置在API项目中。 当我这样做时:
container.Register(Classes.FromAssemblyNamed("WcfServiceWrapper").Pick().WithServiceAllInterfaces());
在运行时,它告诉我ComponentActivator:无法实例化AuthorizationServiceClient 。
我认为它无法从配置文件读取绑定配置,或者我不知道。
您能告诉我如何注册该组件吗?
经过更详细的搜索后,我发现绑定是常见问题。 我必须将所有绑定配置从WcfServiceWrappers app.config
移至APIs web.config
,因此现在所有服务客户端都可以看到构造函数中所需的绑定配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.