使用Unity最低配置 [英] Using Unity With Minimal Configuration

查看:516
本文介绍了使用Unity最低配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中,我们用团结了很多。这是伟大的在它的工作,但你使用它的越多,你的配置文件中生长的越多,运行时问题增加,越多,你必须重新创建为每个测试项目中的统一配置。

At work, we use Unity a lot. It's great at it's job, but the more you use it, the more your configuration file grows, the more runtime issues increase and the more you have to recreate your unity configuration for each test project.

因此,我们最终与具有翻过几个项目被复制,当谈到时间部署,你最终不得不追查你忘记添加到引用的DLL一个巨大的统一配置部分,但只在运行时发现这些。不好玩。

So we end up with a huge unity configuration section that has to be duplicated accross several projects and when it comes time to deploy, you end up having to track down dlls that you forgot to add references to, but you only discover these at runtime. Not fun.

我猜有人碰到过这个问题,有一个解决方案。理想情况下,我想弄清楚如何的方式,利用约定优于配置,并减少运行时问题(即巨大的配置文件)配置统一。 ?任何人都知道的最小配置,才能实现统一的好办法

I'm guessing someone has come across this issue and has a solution. Ideally, I would like to figure out how to configure Unity in a way that makes use of convention over configuration and reduces runtime issues (ie, huge configuration files). Anyone know of a good way to implement Unity with minimal configuration?

编辑:一件事:我要坚持,只有使用统一。真的不能切换到Ninject等。

One thing: I have to stick with only using Unity. Can't really switch to Ninject, etc.

推荐答案

统一有一个配置API,因此它很容易写一些自动配置。使用反射代码

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基于-registration.aspx

http://geekswithblogs.net/brians/archive/2010/07/04/convention-based-注册扩展-换了,微软单位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.

这篇关于使用Unity最低配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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