I'm using Prism and Unity.
I've got this bootstrapper:
protected override IModuleCatalog GetModuleCatalog()
{
ModuleCatalog catalog = new ModuleCatalog()
.AddModule(typeof(CustomerModule.CustomerModule))
.AddModule(typeof(EmployeesModule.EmployeesModule))
.AddModule(typeof(MenuModule.MenuModule));
return catalog;
}
And my CustomerModule gets a MenuManager injected and adds menu items to it:
public void Initialize()
{
menuManager.MenuItems.Add("Customers");
menuManager.MenuItems.Add("Other Customers");
}
But when my MainMenuPresenter object also gets MenuManager injected, it is not the same object:
public MainMenuPresenter(MainMenuView view, MenuManager menuManager)
{
View = view;
View.DataContext = this;
foreach (string menuItemTitle in menuManager.MenuItems)
{
MenuItems.Add(menuItemTitle);
}
}
How do I tell Prism/Unity that I want the injected MenuManager to be a Singleton so that the same object is injected into each of my modules and objects?