JohnSon:基于MefBootstrapper的Bootstrapper

public class Bootstrapper : MefBootstrapper
    {
        ModuleCatalog moduleCatalog;

        protected override void InitializeShell()
        {
            base.InitializeShell();

            Application.Current.RootVisual = (UIElement)Shell;
        }

        protected override DependencyObject CreateShell()
        {
            return Container.GetExportedValue<Shell>();
        }

        protected override void ConfigureAggregateCatalog()
        {
            base.ConfigureAggregateCatalog();
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(this.GetType().Assembly));
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            this.Container.ComposeExportedValue<ModuleCatalog>(this.moduleCatalog);
        }

        /// <summary>
        /// 以文件配置加载模块信息
        /// </summary>
        /// <returns></returns>
        protected override IModuleCatalog CreateModuleCatalog()
        {
            //
            moduleCatalog = Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/KJ;component/ModulesCatalog.xaml", UriKind.Relative));
            return moduleCatalog;
        }

        /// <summary>
        /// 以代码来加载模块信息
        /// </summary>
        /// <returns></returns>
        //protected override IModuleCatalog CreateModuleCatalog()
        //{
        //    ModuleCatalog moduleCatalog = new ModuleCatalog();

        //    //moduleCatalog.AddModule
        //    //(
        //    //    new ModuleInfo
        //    //    {
        //    //        InitializationMode = InitializationMode.OnDemand,
        //    //        Ref = "ModuleA.xap",
        //    //        ModuleName = "ModuleARegion",
        //    //        ModuleType = "ModuleA.ModuleARegion, ModuleA"
        //    //    }
        //    //);

        //    //moduleCatalog.AddModule
        //    //(
        //    //    new ModuleInfo
        //    //    {
        //    //        Ref = "ModuleLogin.xap",
        //    //        ModuleName = "ModuleLogin",
        //    //        ModuleType = "ModuleLogin.ModuleLogin, ModuleLogin"
        //    //    }
        //    //);

        //    moduleCatalog.AddModule
        //    (
        //        new ModuleInfo
        //        {
        //           // InitializationMode = InitializationMode.OnDemand,
        //            Ref = "ModuleMain.xap",
        //            ModuleName = "ModuleMain",
        //            ModuleType = "ModuleMain.ModuleMain, ModuleMain"
        //        }
        //    );

        //    return moduleCatalog;
        //}

你可能感兴趣的:(bootstrap)