Constructor Injection question.

Oct 5, 2009 at 1:22 PM


I hope this is a simple question. I have a PresentationModel with the following constructor.

MyPresentationModel(Contatiner container, IView view);

Sadly Unity does not know what concrete type of IView to create when it attempts to build up the presentation model. To get around this I have changed the signature to.

MyPresentationModel(Contatiner container, MyConcreteTypeView view);

Is there anyway to give unity the information needed to resloved the correct object from the IVew strategy? So I can go back to haveing all of my constructors having a IView parameter?




Oct 6, 2009 at 6:21 PM

Hi Brett,

To enable the Unity Container to resolve objects through an interface, you first have to register the type mappings. You can check the Prism-v2 RI which does this (usually when modules are initialized).

Please let me know if this helps.

Damian Schenkelman