IoC 容器、WCF 和 IoC 容器服务主机工厂

发布于 2024-12-07 17:45:05 字数 436 浏览 0 评论 0原文

我最近一直在阅读有关 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

澜川若宁 2024-12-14 17:45:05

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文