views:

261

answers:

1

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.

+1  A: 

Have you tried something like an extension, have a look at,

http://stackoverflow.com/questions/878994/is-there-tryresolve-in-unity/901783#901783

and see if it help you out.

Johan Leino
I think that this answers the question. Thanks! I'm still not sure if this is the right way to go. I did think about using a shared container for the common elements and a child container for the specifics, but then you have 3 files instead of 2!
No More Hacks