I'm registering few modules in my Prism application using UnityBootstrapper
protected override IModuleCatalog GetModuleCatalog()
{
var catalog = new ModuleCatalog();
catalog
.AddModule(typeof(LoginModule))
.AddModule(typeof(AppModule))
.AddModule(typeof(DataTransformationModule), InitializationMode.OnDemand)
.AddModule(typeof(SyncModule), InitializationMode.OnDemand);
return catalog;
}
Later I'm loading those modules which are set to load OnDemand dynamically in response to user actions. Though I were able to load modules OnDemand from other modules, types I registered in OnDemand loading modules were not getting Resolved.
public class SyncModule : IModule
{
private readonly IUnityContainer container;
public SyncModule(IUnityContainer container)
{
this.container = container;
}
public void Initialize()
{
this.RegisterViewsAndServices();
ISyncController controller = this.container.Resolve<ISyncController>();
controller.Run();
}
protected void RegisterViewsAndServices()
{
this.container.RegisterType<ISyncController, SyncController>();
this.container.RegisterType<ISyncAnchorsRepository, SyncAnchorsRepository>();
this.container.RegisterType<ISyncService, SyncService>();
this.container.RegisterType<IView, SynchronizeView>("SynchronizeView");
this.container.RegisterType<IView, SyncTrayView>("SyncTrayView");
}
}
When I try to load any of the types registered in SyncModule (shown above) from another Module compiler throws an ResolutionFailedException since each module is . Is there anyway to inject same instance of IUnityContainer to all Modules? (Is it going to be a abuse of Prism?)