IoC 容器、WCF 和 IoC 容器服务主机工厂
我最近一直在阅读有关 IoC 的内容,我认为它肯定会在我正在开发的 WCF web-service 中派上用场。然而,Ninject、StructureMap 和 Spring.Net(我只检查了这三个)似乎需要将自定义 Factory
属性添加到 *.svc
文件中
<%@ ServiceHost Language="C#" Debug="true" Service="SomeService" CodeBehind="SomeService.svc.cs" Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>
:问题是,由于将部署服务的系统架构,我已经在使用自定义工厂,这是该项目的必备条件(要求)。我能以某种方式克服这种情况吗?
I have been reading about IoC lately, and I think it would definitely come in handy in the WCF web-service I am developing. However, it seems that Ninject, StructureMap and Spring.Net (I only did check these three) require the custom Factory
attribute to be added to the *.svc
file:
<%@ ServiceHost Language="C#" Debug="true" Service="SomeService" CodeBehind="SomeService.svc.cs" Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>
The problem is that, due to the architecture of the system where the service will be deployed, I am already using a custom factory which is a must-have (a requirement) for this project. Can I somehow overcome this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Autofac 也使用自定义工厂,我怀疑它们都会这样做,因为这给出了IoC 容器有机会参与服务创建过程。其中大多数(全部?)都是开源的,因此您可能想浏览它们的源代码,看看是否可以将 IoC 自定义工厂包装在您的工厂中,或者修改源代码以集成它们。
Autofac also uses a custom factory, and I suspect they all will since this gives the IoC container a chance to be involved in the service creation process. Most (all?) of these are open source, so you might want to browse their source code and see if it would be possible to wrap the IoC custom factory in yours, or modify the source to integrate them.