Resolve IEventAggregator

Topics: Prism v2 - Silverlight 4, Prism v4 - WPF 4
Jul 12, 2010 at 3:54 PM

Hello! 

I've got IUnityConainter inside my class. Is it possible to resolve IEventAggregator using unity container? I don't want to change semantics of class library and base interfaces.

Thanks!

Jul 15, 2010 at 6:10 PM

So long as IEventAggregator is registered with the container (and it should be if you are using the container created by the bootstrapper), you should be able to just call Resolve with something like this (coded in a browser, not VS, so there may be a typo):

IEventAggregator eventAggregator = myContainer.Resolve<IEventAggregator>();

Of course, if the class is already being created by the unity container (via a Resolve call), then you could add a constructor parameter for the event aggregator and have it injected for you. For an example, take a look at the StockTrader RI and find the NewsController class.

 

I hope that helps,

Michael Puleio