Using Unity With Minimal Configuration

孤街醉人 提交于 2019-11-30 14:12:16
Ade Miller

Unity has a configuration API so it's pretty easy to write some auto-configuration code using reflection.

Several people have blogged about it here:

http://geekswithblogs.net/watsonjon/archive/2009/09/28/unity-convention-based-registration.aspx

http://geekswithblogs.net/brians/archive/2010/07/04/convention-based-registration-extension-for-the-microsoft-unity-ioc-container.aspx

Including this one with some framework code you can reuse:

http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/

This has been discussed on the Unity discussion board. The issue is that everyone wants different conventions. Look at the blog posts, writing your own seems pretty trivial.

In unity 3.0 you can now do configuration by convention. This blog post explains it in more detail:

http://blogs.msdn.com/b/agile/archive/2013/03/12/unity-configuration-registration-by-convention.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!