c# /。NET依赖注入框架值得一看? 你对它们的复杂性和速度有什么看法?


当前回答

Autofac。https://github.com/autofac/Autofac它真的很快,很好。这里有一个比较链接(在Ninject修复内存泄漏问题后)。

http://www.codinginstinct.com/2008/05/ioc-container-benchmark-rerevisted.html

其他回答

c#的伟大之处在于,它遵循了多年来Java开发人员所走过的道路。所以,我的建议是,一般来说,在寻找这种性质的工具时,寻找可靠的Java答案,看看是否存在。net的改编。

因此,当涉及到DI时(有很多选择,这真的是一个品味问题)是Spring.NET。此外,研究项目背后的人总是明智的。我建议使用SourceGear产品进行源代码控制(在使用它们之外),因为我尊重Eric Sink。我看过马克·波拉克的演讲,我能说什么呢,他就是懂。

最后,有很多依赖注入框架,您最好的选择是使用其中的一些做一些示例项目,并做出明智的选择。

好运!

我认为Ninject是一个很好的开始,它是新的,已经考虑了很多微调,而且非常快。Nate,开发人员,真的有一个很好的网站和很好的支持。

春天。Net是非常可靠的,但是文档花了一些时间。Autofac很好,虽然支持。net 2.0,但你需要VS 2008来编译它,或者使用命令行来构建你的应用程序。

Autofac。https://github.com/autofac/Autofac它真的很快,很好。这里有一个比较链接(在Ninject修复内存泄漏问题后)。

http://www.codinginstinct.com/2008/05/ioc-container-benchmark-rerevisted.html

这取决于你在寻找什么,因为它们都有各自的优点和缺点。

Spring.NET is the most mature as it comes out of Spring from the Java world. Spring has a very rich set of framework libraries that extend it to support Web, Windows, etc. Castle Windsor is one of the most widely used in the .NET platform and has the largest ecosystem, is highly configurable / extensible, has custom lifetime management, AOP support, has inherent NHibernate support and is an all around awesome container. Windsor is part of an entire stack which includes Monorail, Active Record, etc. NHibernate itself builds on top of Windsor. Structure Map has very rich and fine grained configuration through an internal DSL. Autofac is an IoC container of the new age with all of it's inherent functional programming support. It also takes a different approach on managing lifetime than the others. Autofac is still very new, but it pushes the bar on what is possible with IoC. Ninject I have heard is more bare bones with a less is more approach (heard not experienced). The biggest discriminator of Unity is: it's from and supported by Microsoft (p&p). Unity has very good performance, and great documentation. It is also highly configurable. It doesn't have all the bells and whistles of say Castle / Structure Map.

总之,这取决于什么对你来说是重要的。我同意其他人的看法,去评估,看看哪一个合适。好处是你有很多甜甜圈可以选择,而不仅仅是果冻甜甜圈。