private void SetupStyleMVVMBootstrapper()
        {
            if (!Bootstrapper.HasInstance)
            {
                var bootstrapper = new Bootstrapper();

                bootstrapper.Container.RegisterAssembly(application.GetType().GetTypeInfo().Assembly);

                bootstrapper.Start();
            }
        }
        /// <summary>
        /// Creates a new Design time bootstrapper if DesignModeEnabled is true
        /// and there isn't a bootstrapper already
        /// </summary>
        public static IExportLocator GetDesignTimeExportLocatorInstance(FrameworkElement frameworkElement)
        {
            IExportLocator returnValue = null;

            if (returnValue == null &&
                 DesignModeUtility.DesignModeIsEnabled)
            {
                if (!Bootstrapper.HasInstance)
                {
                    try
                    {
                        IBootstrapper newBootStrapper = new Bootstrapper(ExportEnvironment.DesignTime);

                        newBootStrapper.Start();
                    }
                    catch (Exception)
                    {
                    }
                }

                if (Application.Current != null)
                {
                    List<Assembly> designTimeAssemblies = new List<Assembly>();
                    List<IConfigurationModule> configurationModules = new List<IConfigurationModule>();

                    FindAllDesignTimeObjects(Application.Current.Resources, designTimeAssemblies, configurationModules);

                    returnValue = Bootstrapper.Instance.Container.CreateChildScope(
                        c =>
                        {
                            foreach (Assembly designTimeAssembly in designTimeAssemblies)
                            {
                                var localAssembly = designTimeAssembly;

                                c.ExportAssembly(localAssembly);
                            }

                            foreach (IConfigurationModule configurationModule in configurationModules)
                            {
                                configurationModule.Configure(c);
                            }
                        });

                }
            }

            return returnValue;
        }
Exemplo n.º 3
0
        private void CreateBootstrapper()
        {
            if (!Bootstrapper.HasInstance)
            {
                Bootstrapper newBootstrapper = new Bootstrapper();

                newBootstrapper.Container.RegisterAssembly(GetType().GetTypeInfo().Assembly);

                newBootstrapper.Start();
            }
        }