Where should I put my singletons...

Topics: Prism v4 - WPF 4
Nov 27, 2013 at 2:30 PM
First project using Prism...
First real project in WPF...

Where should I put my singleton services?
I have an infrastructure project (interfaces, regionNames, etc.) and we also put the implementation of some interfaces in this infrastructure projects. Essentially singletons services available to all modules.

It works if those singletons are used in modules, since the bootstrapper register those services...
But what about other objects in the infrastructure if they need a singleton's instance? cannot be tested without bootsrapper registration? I could possibly add a typical GetInstance() fct and use it... but am I wrong?

I'm now thinking about creating a Common assembly different from the infrastructure. A prism module...

Something to declare??
Nov 27, 2013 at 5:10 PM
Hi mt_x,

Based on my understanding, services are meant to be used on cross-module communications.
I think you could find helpful the following MSDN Prism chapter at SharedServices section:

Furthermore, you can see the StockTrader Reference Implementation documentation for Common assembly configuration details:

I hope you find this useful,

Gabriel Ostrowsky
Dec 5, 2013 at 9:40 AM
Hi mt_x,
As per my understanding from your post you are trying to use single instance of service object in different modules. If this is that case than i think you can achieve this by
registering service in unity container and get that service by using service locator class in your different modules.

Hoping this will help you.

Pankaj Goswami