如果您要开始一个新的 MVC3 项目,您会选择 DependencyResolver 还是 ControllerFactory 和 Castle Windsor 哪种适配?
我是 ioc 容器的新手,并且对如何将容器集成到 mvc3 感到困惑...
有一个使用 ControllerFactory 的示例... https://github.com/kkozmic/ToBeSeen/ blob/master/src/ToBeSeen/Plumbing/WindsorControllerFactory.cs
有一篇博客文章说 “MVC 3.0 IDependencyResolver 接口已损坏。请勿将其与 Windsor 一起使用。” http://mikehadlow.blogspot.com/2011/ 02/mvc-30-idependencyresolver-interface-is.html
从这个链接我想我还需要实现 IControllerActivator... MVC 3 的 Castle Windsor 依赖解析器
在pluralsight 的 mvc3 依赖解析视频中allen 说如果你的 ioc 容器不足以容纳它,那么使用激活器是必要的...... 这也让我考虑将 Windsor 与 DependencyResolver 一起使用。
I am new to the ioc containers and confused how to integrate a container to mvc3...
There is a sample that uses ControllerFactory...
https://github.com/kkozmic/ToBeSeen/blob/master/src/ToBeSeen/Plumbing/WindsorControllerFactory.cs
There is a blog post that says
"The MVC 3.0 IDependencyResolver interface is broken. Don’t use it with Windsor."
http://mikehadlow.blogspot.com/2011/02/mvc-30-idependencyresolver-interface-is.html
and from this link I think I also need to implement IControllerActivator...
Castle Windsor Dependency Resolver for MVC 3
In pluralsight's mvc3 dependency resolution videos scot allen says using activators is necessary if your ioc container is not enough for it...
this also makes me think about using windsor with DependencyResolver.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 ControllerFactory 一段时间以来没有任何问题。
有一个非常有用的 教程温莎维基上的
如果您需要 IoC 解决您的操作,我建议您
http://weblogs.asp.net/psteele/archive/2009/11/04/using-windsor-to-inject-dependency-into-asp-net-mvc-actionfilters.aspx
由于缺少释放操作,IDependencyResolver 还不够:远离它。
I'm using ControllerFactory since a while with no problem at all.
There's a very usefull tutorial on windsor wiki
In case you need your action been resolved by an IoC I suggest you
http://weblogs.asp.net/psteele/archive/2009/11/04/using-windsor-to-inject-dependencies-into-asp-net-mvc-actionfilters.aspx
Due to missing release operation, IDependencyResolver is not enough: stay away from it.