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


当前回答

我花了大半天的时间苦苦挣扎,只为得到最简单的泉水。NET实例工作。永远不知道如何让它从XML文件中找到我的程序集。另一方面,在大约2小时内,我能够让Ninject工作,包括测试与NUnit和MSTest的集成。

其他回答

我花了大半天的时间苦苦挣扎,只为得到最简单的泉水。NET实例工作。永远不知道如何让它从XML文件中找到我的程序集。另一方面,在大约2小时内,我能够让Ninject工作,包括测试与NUnit和MSTest的集成。

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

Ninject很棒。看起来真的很快,但我没有做过任何比较。我知道作者Nate在Ninject和其他DI框架之间做了一些比较,并且正在寻找更多的方法来提高Ninject的速度。

我听很多我尊敬的人说过StructureMap和CastleWindsor的优点。在我看来,这是目前最值得关注的三大问题。

我是卡塞尔的超级粉丝。我喜欢它提供的IoC容器之外的功能。它真的简化了使用NHibernate,日志,AOP等。我还使用Binsor来配置Boo,并因此真正爱上了Boo这门语言。

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

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.

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