将 Ninject WCF 扩展与 WCF Web 服务结合使用 [英] Using Ninject WCF Extension with WCF Web Service

查看:25
本文介绍了将 Ninject WCF 扩展与 WCF Web 服务结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF web 服务,我想在其中使用我的存储库和服务,我希望将它们依赖注入到我的 WCF web 服务中,但是 Ninject WCF 扩展示例几乎有一个 ctor,它正在实例化每个依赖项的一个实例,我不想要,我想要一个更纯粹的依赖注入.

I have a WCF web service in which I want to use my Repositories and Services which I wish to dependency inject into my WCF web service, however the Ninject WCF Extension example pretty much has a ctor which is instantiating an instance of each dependency, which I don't want, I wanted a purer dependency injection.

有没有人在 WCF 中使用 Ninject 取得任何成功,Google 似乎对我正在寻找的主题几乎没有返回相关结果.

Has anyone had any success with using Ninject with WCF, Google seems to return little relevant results for the topics I am looking for.

推荐答案

TimeService 有:

<%@ ServiceHost Language="C#" Debug="true" Service="WcfTimeService.TimeService" CodeBehind="TimeService.svc.cs" **Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory"** %>

私生子注射 行为者混淆了这件事 - Ninject 会选择最具体的构造函数.该示例的一般问题是它涵盖了所有基础(IIS 托管、EXE 托管、服务托管),而 WCF 也不能完全使所有这些东西易于管理(@Ian Davis:我很容易出错,你能提供请提供更多详细信息,也许以 README 中示例说明的摘要的形式,或者更详细地说明您使用 BI 的各种情况的原因?)

The bastard injection ctors confuse the matter - Ninject will choose the most specific constructor. The general problem with the sample is that it's covering all the bases (IIS Hosted, EXE hosted, Service Hosted), and WCF doesnt exactly make all this stuff easy to manage either (@Ian Davis: I could easily be wrong, can you provide some more detail please , perhaps in the form of a summary of what the samples illustrate in the README, and perhaps more detail in the why of the various cases where you've used BI?)

这篇关于将 Ninject WCF 扩展与 WCF Web 服务结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆