No More Hacks
No More Hacks

Reputation: 309

Configure unity with one config file for multiple applications

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.

Upvotes: 0

Views: 784

Answers (1)

Johan Leino
Johan Leino

Reputation: 3533

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

Is there TryResolve in Unity?

and see if it help you out.

Upvotes: 1

Related Questions