本文介绍了如何选择一个DI容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  How主要做C#DI / IoC的框架比较?

有这么多的DI容器,我有种丢失。我是新来的DI模式。

There being so many DI containers, I feel kind of lost. I'm new to the DI pattern.

我在读这本书的我发现DI是令人难以置信的有用的改进code基地,使之成为松散耦合和更容易测试。

I'm reading the book Dependency Injection in .NET and I've found DI to be incredible useful in improving a code base, making it loose coupled and more testable.

我现在要介绍一个DI容器我的虚拟项目,但目前只有这么多的选择。

I now want to introduce a DI container for my dummy project, but there are just so many to choose from.

我怎么温莎城堡,团结,StructureMap,Spring.NET,Autofac,Ninject,Funq,李林甫,等等等等?

How am I supposed to choose between Castle Windsor, Unity, StructureMap, Spring.NET, Autofac, Ninject, Funq, LinFu, etc, etc?

我猜一个连贯采取将是随便挑一,并开始使用它(因为我的身影,他们是pretty轻松互换,特别是在早期阶段),但我想做出更明智决定。

I guess a coherent take would be to "just pick one" and start using it (since I figure they're pretty easily interchangeable, specially in the early stages), but I would like to make a more informed decision.

推荐答案

这就像买一辆车。你可能会喜欢一个丰田汽车,但它只是2.5L发动机。你可能会喜欢法拉利,但它太红了。你可能会喜欢马自达,但你的老板不会让你驾驶它。你可能会喜欢悍马,但你的同事会笑话你。混合制造商自己的口味,也总是会若有所失为某人或一些不同的时刻。

This is like buying a car. You might like a Toyota, but it's just 2.5L engine. You might like Ferrari, but it's too red. You might like Mazda, but your boss doesn't allow you to drive it. You might like Hummer, but then your colleagues would laugh at you. Mix the manufacturers to your taste, there's always going to be something missing for somebody or at some different moment.

我的看法是 - 首先,DI通常是更好然后没有DI。挑不出什么,你会好起来的。我会选择一些:

My take is - first and foremost, DI is usually better then not having DI. Pick anything and you'll be better off. I'd pick something that:


  • 的社区(这样你就可以得到答案)良好的支持

  • 具有良好的后盾公司背后(这样你就不会去重写code,当它倒闭)

  • 感觉很好,你(这样你就不会在孩子面前发誓,不是凉)

  • 是不是为项目
  • 矫枉过正
  • 不仅仅是DI,但提供的东西,这将减少你,你知道你可以做任务花费的时间,只是没有现在的生态系统 - 然后你可以专注于重要事物

  • 是用来给很多人(所以你知道,许多地方都在现实生活中和错误也充满测试)

  • 是不是5岁(如文档说,它支持Windows 98或东西)

我的2美分 - 。我的意思是,他们的就像是20页长。 ..

My 2 cents - http://www.springframework.net/. I mean, their documentation contents page is like 20 pages long...

或者你只是可能需要一些更多的答案找一个类似的问题:

Or you just might want to look at some more answers to a similar question:



  • Which .NET Dependency Injection frameworks are worth looking into?

这篇关于如何选择一个DI容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:41