使用一个配置文件为多个应用程序配置 Unity
我有两个密切相关的应用程序,它们都使用 Unity IoC 容器。它们有一些共同的自定义类型,但不是全部。目前我有两个配置文件有很多重复。我想要一个 Unity 配置文件来管理所有这些。
然而,由于并非所有类型都存在于两个应用程序中,Unity 感到不满。我想要的是一种告诉 Unity 不要尝试注册/实例化配置文件中的类型的方法,除非容器需要它们。
我可以想到几个解决方案,但由于我是 Unity 新手,我不想猜测/重新发明。
是的,它一定是 Unity。目前。
I have two closely related applications that are both using the Unity IoC container. They have some custom types in common, but not all of them. At the moment I have two config files that have a lot of duplication. I'd like to have just one Unity config file to rule them all.
However, as not all types exist in both applications Unity is unhappy. What I want is a way to tell Unity not to try and register/instantiate the types in the config file unless the container is asked for them.
I can think of a couple of solutions but as I'm a Unity newbie I don't want to guess/reinvent.
And yes, it must be Unity. For now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是否尝试过类似扩展的东西,看看
Unity 中有 TryResolve ?
看看它是否对您有帮助。
Have you tried something like an extension, have a look at,
Is there TryResolve in Unity?
and see if it help you out.