C# IoC 容器

C# IoC containers

我一直使用C#接口来实现控制反转。但后来我发现这篇文章比较了一堆 IoC 容器。这些容器和 C# 接口有什么区别?

http://www.palmmedia.de/blog/2011/8/30/ioc-container-benchmark-performance-comparison

你做了一个错误的比较。 抽象 是应用依赖注入 和符合Dependency Inversion Principle. If you are applying DI without the help of a container, you are practicing Pure DI 的先决条件。纯 DI 是一种有效的做法。

当应用程序增长时,容器的使用会变得非常方便,因为它们使 Convention over Configuration 能够连接对象图。如果你开始使用 DI 容器,你仍然需要使用 Abstractions.

要了解有关何时以及为何应使用 DI 容器的更多信息,请阅读 this and this