Imagine you have a situation like this:

image

2 MVC controllers (A and B) have a dependency on SvcA. SvcA has a dependency on SvcB and a component implementing IX.SvcB has a dependency on something implementing IY.

Every time the system resolves CtrlA we want to provide Y1 and every time it resolves CtrlB, we want to provide Y2.

Something like this:

image

and

image

 

How would you configure Unity to solve this?

No “if() else” allowed. System supplies its own MVC’s ControllerFactory. (via ControllerBuilder.Current.SetControllerFactory). Ideally, we want the ControllerFactory to have no knowledge of any of these specific components.

Some help: read Chris’s blog and Unity docs.