使用带WCF Web服务的Ninject WCF扩展 [英] Using Ninject WCF Extension with WCF Web Service

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

问题描述

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



有没有人有任何成功使用Ninject与WCF,谷歌似乎返回一点相关的结果为我正在寻找的主题

解决方案

TimeService 具有:

 <%@ ServiceHost Language =C#Debug =trueService =WcfTimeService.TimeServiceCodeBehind =TimeService.svc.cs** Factory =Ninject.Extensions.Wcf.NinjectServiceHostFactory**% > 

混蛋注入 ctors混淆事情 - Ninject将选择最具体的构造函数。该示例的一般问题是它涵盖了所有的基础(IIS Hosted,EXE托管,服务托管),WCF并不完全使所有这些东西容易管理(@Ian Davis:我可以很容易地错了,你能提供请稍后再来一些细节,或者以README中的样本说明为例,以及您为何使用BI的各种情况的更多细节?)


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.

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

解决方案

The code behind for TimeService has:

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

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?)

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

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