简体   繁体   English

n层体系结构中的依赖注入-如何处理

[英]Dependency injection in an n-tier architecture - how to approach

I want to build an N-Tier application. 我想构建一个N层应用程序。

Client (WebJson-MVC, WebSoap-WCF) 客户端(WebJson-MVC,WebSoap-WCF)
API API
BLL BLL
DAL DAL

Client depends on API that depends on BLL that depends in DAL . Client依赖于依赖于DAL BLL API
So lets say that I want to inject API to the clients(WebJson-MVC, WebSoap-WCF) . 因此,可以说我想将API注入客户端(WebJson-MVC,WebSoap-WCF)。
Since there are 2 clients, what is the best way to do the injection? 既然有两个客户,那么进行注射的最佳方法是什么? To which project should I import the Dependency injection frame work? 我应该将依赖项注入框架导入哪个项目?
What is the workaround for this? 解决方法是什么?
Where do I suppose to initialize the context? 我应该在哪里初始化上下文? IApplicationContext ctx = ContextRegistry.GetContext();

Edit 1 编辑1
If I will create the dependency injection in the WebJson-MVC and I want to inject the bll to the api don't I couple the MVC with the BLL, isnt that bad to have the bll and the client tidely coupled? 如果我将在WebJson-MVC中创建依赖项注入,并且想将bll注入到api ,那么我不将MVC与BLL耦合,将bll和客户端进行潮汐耦合是否不好? Also, how do I suppose to inject the API to WebSoap-WCF? 另外,如何将API注入WebSoap-WCF?

Thanks 谢谢

To the WebJson-MVC framework, without question. 毫无疑问,使用WebJson-MVC框架。 Initialization in the MVC framework would be in the ApplicationStart() of the Global.asax.cs file. MVC框架中的初始化将在Global.asax.cs文件的ApplicationStart()中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM