我应该使用哪种依赖注入工具? [英] Which Dependency Injection Tool Should I Use?

查看:24
本文介绍了我应该使用哪种依赖注入工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在我们的用户界面中使用 Microsoft Unity 作为我的依赖注入工具.

I am thinking about using Microsoft Unity for my Dependency Injection tool in our User Interface.

我们的中间层已经在使用 Castle Windsor,但我想我应该坚持使用 Microsoft.

Our Middle Tier already uses Castle Windsor, but I am thinking I should stick with Microsoft.

有人对最好的依赖注入工具有什么想法吗?

Does anyone have any thoughts about what the best Dependency Injection tool is?

推荐答案

如果您的系统在设计时考虑了 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)

Hanselman 有一个 IoC 容器的综合列表

There is a comprehensive list of IoC containers by Hanselman

PS:您不想使用 Unity

PS: You do not want to use Unity

这篇关于我应该使用哪种依赖注入工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆