我正在寻找.net的简单但实用且健壮的IOC/DI框架 [英] I am looking for a simple yet practical and robust IOC/DI framework for .net

查看:149
本文介绍了我正在寻找.net的简单但实用且健壮的IOC/DI框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在经验不足的开发人员的项目中使用它,因此不能选择诸如Spring.NET之类的复杂框架.我在想:

  1. 注入
  2. 温莎城堡
  3. StructureMap

哪个会呈现出适度的学习曲线而又不会失去灵活性?

和另一个问题-放置配置的正确位置在哪里?由于3层ASP.NET应用程序上的内核/配置(不是MVC !!!,所有示例都使用MVC :))

解决方案

正确使用DI的好处在于,您可以将有关使用哪个DI容器的决定推迟到最后责任时刻. .用应用程序体系结构术语来说,这对应于所谓的 Composition Root ,在这里您可以将所有依赖关系连接在一起.这是通常是应用程序的入口点.

除合成根"外,整个应用程序都可以编写,而无需引用任何特定的DI容器.您只需要遵循众所周知的模式和原理.. >

在选择DI容器时,我知道这些用于.NET的DI容器:

就我个人而言,到目前为止,我对温莎城堡感到满意,但是我还没有获得所有这些容器的丰富经验.

I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about:

  1. Ninject
  2. Castle Windsor
  3. StructureMap

Which would present a moderate learning curve without losing flexibility?

and another question - where is the correct place to put the configuration? Since the kernel/configuration on a 3-tier ASP.NET application (not MVC!!! all examples are using MVC :) )

解决方案

The great thing about proper use of DI is that you can defer the decision about which DI Container to use until the last responsible moment. In application architecture terms, this corresponds to a so-called Composition Root, which is where you wire all depedendencies together. This is often the application's entry point.

Apart from the Composition Root, the entire application can be written without referencing any particular DI Container at all. You just need to follow well-known patterns and principles.

When it comes to pick a DI Container, I'm aware of these DI Containers for .NET:

Personally, I have been happy with Castle Windsor so far, but I have yet to gain extensive experience with all of these containers.

这篇关于我正在寻找.net的简单但实用且健壮的IOC/DI框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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