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 understading, your issues could be fixed the following way:

1- Regarding the Log lines, they are related to Prism debugging and you can remove them since they don't affect the functionality of your application

2- Regarding the problem with the ModuleCatalog, if you need to use UserPrincipal at the time you are configuring your ModuleCatalog, then you can just include it to the section of the code that was related to this UserPrincipal. Therefore, your Bootstrapper should look like this:
publicoverridevoid Run(bool runWithDefaultConfiguration)
{
    this.useDefaultConfiguration = runWithDefaultConfiguration;

    this.Logger = this.CreateLogger();
    if (this.Logger == null)
    {
        thrownew InvalidOperationException("NullLoggerFacadeException");
    }

    this.Container = this.CreateContainer();
    if (this.Container == null)
    {
        thrownew InvalidOperationException("NullUnityContainerException");
    }

    this.ConfigureContainer();

    this.ConfigureServiceLocator();

    this.ConfigureRegionAdapterMappings();

    this.ConfigureDefaultRegionBehaviors();

    this.RegisterFrameworkExceptionTypes();

    this.Shell = this.CreateShell();
    if (this.Shell != null)
    {
        RegionManager.SetRegionManager(this.Shell, this.Container.Resolve<IRegionManager>());

        RegionManager.UpdateRegions();

        this.InitializeShell();
    }
            
    if (this.Container.IsRegistered<IModuleManager>())
    {
        //Patch to wait for the userPrincipal before initializing the modulesif (userPrincipal.UserID == 0)
        {
            ServiceLocator.Current.GetInstance<IEventAggregator>().GetEvent<UserInitialized>().Subscribe(this.UserDone);
        }
        else
        {
            this.DoModuleConfig();
        }
    }
}

publicvoid UserDone(UserPrincipal user)
{
    ServiceLocator.Current.GetInstance<IEventAggregator>().GetEvent<UserInitialized>().Unsubscribe(this.UserDone);
    this.DoModuleConfig();
}

publicvoid DoModuleConfig()
{
    this.ModuleCatalog = this.CreateModuleCatalog();
    if (this.ModuleCatalog == null)
    {
        thrownew InvalidOperationException("NullModuleCatalogException");
    }

    this.ConfigureModuleCatalog();
    this.InitializeModules();
}
Hope this helps,

Federico Martinez
http://blogs.southworks.net/fmartinez

Viewing all articles
Browse latest Browse all 1878

Trending Articles



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