Dynamically Loading ModuleCatalog in Composite (PRISM) Silverlight Application
Intercept the Run method of your bootstrapper by defining a new Run method, fetch the list of modules (list trimmed to the user in question of course) and populate the catalog from this.
poc code?
Here you are (note I am using a custom RIA domain service to trim the list of modules)
public class Bootstrapper : UnityBootstrapper
{
ModuleCatalog catalog = new ModuleCatalog();
new public void Run()
{
AuthenticationContext ctx = new AuthenticationContext();
EntityQuery<Module> query = ctx.GetModulesQuery();
ctx.Load<Module>(query, loadOperation =>
{
if (loadOperation.HasError)
{
throw new Exception("Not able to load catalog");
}
foreach (var item in ctx.Modules)
{
catalog.AddModule(new ModuleInfo()
{
InitializationMode = (InitializationMode)Enum.Parse(typeof(InitializationMode), item.InitializationMode, true),
ModuleName = item.Name,
ModuleType = item.TypeName,
Ref = item.Xap
});
}
base.Run();
},null);
}
protected override DependencyObject CreateShell()
{
Shell shell = Container.Resolve<Shell>();
Application.Current.RootVisual = shell;
return shell;
}
protected override IModuleCatalog GetModuleCatalog()
{
return catalog;
}
}
Comments
Anonymous
February 28, 2010
Hey So you finally made an update to your blog... Awesome! ;o)Anonymous
June 11, 2010
How do you know who the user in question is?