其中.NET依赖注入框架是值得研究的? [英] Which .NET Dependency Injection frameworks are worth looking into?

查看:345
本文介绍了其中.NET依赖注入框架是值得研究的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中C#/。NET的依赖注入框架是值得研究的? 什么,你能说他们的复杂程度和速度。

Which C#/.NET Dependency Injection frameworks are worth looking into? And what can you say about their complexity and speed.

推荐答案

我想我会在这里是有点挑剔,但重要的是要注意的是DI(依赖注入)是一种编程模式,并通过促进,但不要求,一个IoC框架(控制反转)。国际奥委会框架只是让DI更容易,他们提供了许多超出DI其他好处。

I suppose I might be being a bit picky here but it's important to note that DI (Dependency Injection) is a programming pattern and is facilitated by, but does not require, an IoC (Inversion of Control) framework. IoC frameworks just make DI much easier and they provide a host of other benefits over and above DI.

话虽这么说,我敢肯定这就是你问。关于IoC的框架;我曾经使用 Spring.Net 和的 CastleWindsor 的很多,但背后真正的痛苦是所有讨厌的XML配置,你必须写!他们是pretty的很多现在都提出这个办法,所以我一直在使用 StructureMap 在过去一年左右的时间,而且因为它已经转移到使用强类型泛型和注册表一口流利的配置,使用的IoC我痛苦的障碍已降至零下!我得到一个绝对踢出来知道现在我的IoC的配置,那么在编译时检查(大部分)和我有什么,但喜悦StructureMap和速度。我就不说了,其他人都在运行时慢,但他们比较困难,他设置和挫折往往占了上风。

That being said, I'm sure that's what you were asking. About IoC Frameworks; I used to use Spring.Net and CastleWindsor a lot, but the real pain in the behind was all that pesky XML config you had to write! They're pretty much all moving this way now, so I have been using StructureMap for the last year or so, and since it has moved to a fluent config using strongly typed generics and a registry, my pain barrier in using IoC has dropped to below zero! I get an absolute kick out of knowing now that my IoC config is checked at compile-time (for the most part) and I have had nothing but joy with StructureMap and its speed. I won't say that the others were slow at runtime, but they were more difficult for me to setup and frustration often won the day.

更新

我一直使用 Ninject 对我的最新项目,它一直是绝对的快乐使用。字在这里让我失望了一点,但(正如我们所说,在英国)这个框架是'狗'。我会极力推荐它,你想快速启动和运行任何绿色领域的项目。我得到了所有我需要从梦幻般的一套由Justin Etheredge 的Ninject截屏。我看不到加装Ninject到现有code被在所有问题,但 StructureMap的那么同样可以说, 在我的经验。这将是一个艰难的选择前进这两者之间,但我宁愿比停滞竞争,有良性竞争,在那里的一个像样的数目。

I've been using Ninject on my latest project and it has been an absolute pleasure to use. Words fail me a bit here, but (as we say in the UK) this framework is 'the Dogs'. I would highly recommend it for any green fields projects where you want to be up and running quickly. I got all I needed from a fantastic set of Ninject screencasts by Justin Etheredge. I can't see that retro-fitting Ninject into existing code being a problem at all, but then the same could be said of StructureMap in my experience. It'll be a tough choice going forward between those two, but I'd rather have competition than stagnation and there's a decent amount of healthy competition out there.

其他国际奥委会的截屏也可以找到这里Dimecasts

Other IoC screencasts can also be found here on Dimecasts.

这篇关于其中.NET依赖注入框架是值得研究的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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