Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Gathering User Information before Bootstrapper Runs

$
0
0
Hi,

Based on my understanding, the default ConfigureContainer method of the bootstrapper tries to register the ModuleCatalog in the container. However, as we delayed the creation of the ModuleCatalog until the DoModuleConfig is executed, the ConfigureContainter method fails. A possible approach to workaround this is to include the logic of the original ConfigureContainer method in the overriding version but without registering the ModuleCatalog. Then, you could register the ModuleCatalog in the DoModuleConfig method. As a result, your ConfigureContainer method should be like this:
protectedoverridevoid ConfigureContainer()
{
    this.Container.AddNewExtension<UnityBootstrapperExtension>();

    Container.RegisterInstance<ILoggerFacade>(Logger);

    RegisterTypeIfMissing(typeof(IServiceLocator), typeof(UnityServiceLocatorAdapter), true);
    RegisterTypeIfMissing(typeof(IModuleInitializer), typeof(ModuleInitializer), true);
    RegisterTypeIfMissing(typeof(IModuleManager), typeof(ModuleManager), true);
    RegisterTypeIfMissing(typeof(RegionAdapterMappings), typeof(RegionAdapterMappings), true);
    RegisterTypeIfMissing(typeof(IRegionManager), typeof(RegionManager), true);
    RegisterTypeIfMissing(typeof(IEventAggregator), typeof(EventAggregator), true);
    RegisterTypeIfMissing(typeof(IRegionViewRegistry), typeof(RegionViewRegistry), true);
    RegisterTypeIfMissing(typeof(IRegionBehaviorFactory), typeof(RegionBehaviorFactory), true);
    RegisterTypeIfMissing(typeof(IRegionNavigationJournalEntry), typeof(RegionNavigationJournalEntry), false);
    RegisterTypeIfMissing(typeof(IRegionNavigationJournal), typeof(RegionNavigationJournal), false);
    RegisterTypeIfMissing(typeof(IRegionNavigationService), typeof(RegionNavigationService), false);
    RegisterTypeIfMissing(typeof(IRegionNavigationContentLoader), typeof(RegionNavigationContentLoader), true);

    Container.RegisterInstance(typeof(UserPrincipal), userPrincipal, new ContainerControlledLifetimeManager());
}
And the DoModuleConfig like this:
publicvoid DoModuleConfig()
{
    this.ModuleCatalog = this.CreateModuleCatalog();
    if (this.ModuleCatalog == null)
    {
        thrownew InvalidOperationException("NullModuleCatalogException");
    }

    this.Container.RegisterInstance(this.ModuleCatalog);

    this.ConfigureModuleCatalog();
    this.InitializeModules();
}
Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Viewing all articles
Browse latest Browse all 1878

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>