我应该使用哪种依赖注射工具? [英] Which Dependency Injection Tool Should I Use?
问题描述
我正在考虑在我们的用户界面中为我的依赖注入工具使用Microsoft Unity。
I am thinking about using Microsoft Unity for my Dependency Injection tool in our User Interface.
我们的中间层已经使用了城堡温莎,但我在想我应该坚持有没有人对什么是最好的依赖注入工具有什么想法?
Our Middle Tier already uses Castle Windsor, but I am thinking I should stick with Microsoft.
- Autofac
- Castle MicroKernel / Windsor
- PicoContainer.NET
- Puzzle.NFactory
- Spring.NET
- StructureMap
- Ninject
- Unity
- 简单注射器
- NauckIT.MicroKernel
- WINTER4NET
- ObjectBuilder
- Autofac
- Castle MicroKernel/Windsor
- PicoContainer.NET
- Puzzle.NFactory
- Spring.NET
- StructureMap
- Ninject
- Unity
- Simple Injector
- NauckIT.MicroKernel
- WINTER4NET
- ObjectBuilder
推荐答案
到一个容器不是很重要,如果你的系统设计了IoC / DI的想法。通过适当的方法,您可以轻松地将IoC库轻松更改。
Sticking to one container is not really important, if your system has been designed with the IoC/DI in mind. With the proper approach you can easily change the IoC library down the road.
当然,容器必须提供足够的灵活性来支持常用的广泛使用的方案(生命周期管理,适当的容器嵌套,XML和代码配置,截取,快速分辨率)。
And, of course, the container has to provide enough flexibility to support common widely used scenarios (lifecycle management, proper container nesting, XML and code configuration, interception, fast resolution).
我建议选择Castle之间(广泛使用并拥有大量的集成库)和Autofac(轻量级,快速且具有适当的容器嵌套,但不是广泛使用)
I'd recommend to pick between Castle (widely used and have a lot of integration libraries) and Autofac (lightweight, fast and has proper container nesting, but is not that widely used)
有一个 IoC容器的综合列表 by Hanselman
There is a comprehensive list of IoC containers by Hanselman
PS:你不想使用Unity
PS: You do not want to use Unity
这篇关于我应该使用哪种依赖注射工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!