Exemple #1
0
        public virtual void TestCanResolve()
        {
            using (IIocContainer iocContainer = GetIocContainer())
            {
                iocContainer.CanResolve(typeof(ISimple)).ShouldBeFalse();
                iocContainer.CanResolve <ISimple>().ShouldBeFalse();

                iocContainer.BindToConstant <ISimple>(new Simple());

                iocContainer.CanResolve(typeof(ISimple)).ShouldBeTrue();
                iocContainer.CanResolve <ISimple>().ShouldBeTrue();
            }
        }
 /// <summary>
 ///     Sets the <see cref="IocContainer" />.
 /// </summary>
 public static void Initialize(IIocContainer iocContainer, PlatformInfo platform)
 {
     Should.NotBeNull(iocContainer, "iocContainer");
     ApplicationSettings.Platform = platform;
     _iocContainer = iocContainer;
     TryInitialize(iocContainer, ref _tracer);
     TryInitialize(iocContainer, ref _reflectionManager);
     TryInitialize(iocContainer, ref _attachedValueProvider);
     TryInitialize(iocContainer, ref _threadManager);
     TryInitialize(iocContainer, ref _operationCallbackFactory);
     TryInitialize(iocContainer, ref _validatorProvider);
     TryInitialize(iocContainer, ref _viewModelProvider);
     TryInitialize(iocContainer, ref _eventAggregator);
     if (iocContainer.CanResolve <IViewModelSettings>())
     {
         ApplicationSettings.ViewModelSettings = iocContainer.Get <IViewModelSettings>();
     }
 }
Exemple #3
0
        public virtual void TestCanResolveNamed()
        {
            const string name = "name";

            using (IIocContainer iocContainer = GetIocContainer())
            {
                iocContainer.CanResolve(typeof(ISimple), name).ShouldBeFalse();
                iocContainer.CanResolve <ISimple>(name).ShouldBeFalse();

                iocContainer.BindToConstant <ISimple>(new Simple());

                iocContainer.CanResolve(typeof(ISimple), name).ShouldBeFalse();
                iocContainer.CanResolve <ISimple>(name).ShouldBeFalse();

                iocContainer.BindToConstant <ISimple>(new Simple(), name);

                iocContainer.CanResolve(typeof(ISimple), name).ShouldBeTrue();
                iocContainer.CanResolve <ISimple>(name).ShouldBeTrue();
            }
        }
Exemple #4
0
        /// <summary>
        /// Run the bootstrapper process.
        /// </summary>
        /// <param name="runWithDefaultConfiguration">If <see langword="true"/>, registers default Prism Library services in the container. This is the default behavior.</param>
        public override void Run(bool runWithDefaultConfiguration)
        {
            _useDefaultConfiguration = runWithDefaultConfiguration;

            Logger = CreateLogger();
            if (Logger == null)
            {
                throw new InvalidOperationException(Resources.NullLoggerFacadeException);
            }

            Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low);

            Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low);
            ModuleCatalog = CreateModuleCatalog();
            if (ModuleCatalog == null)
            {
                throw new InvalidOperationException(Resources.NullModuleCatalogException);
            }

            Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low);
            ConfigureModuleCatalog();

            Logger.Log(Resources.CreatingMunqContainer, Category.Debug, Priority.Low);
            Container = CreateContainer();
            if (Container == null)
            {
                throw new InvalidOperationException(Resources.NullMunqContainerException);
            }

            Logger.Log(Resources.ConfiguringMunqContainer, Category.Debug, Priority.Low);
            ConfigureContainer();

            Logger.Log(Resources.ConfiguringServiceLocatorSingleton, Category.Debug, Priority.Low);
            ConfigureServiceLocator();

            Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low);
            ConfigureViewModelLocator();

            Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low);
            ConfigureRegionAdapterMappings();

            Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low);
            ConfigureDefaultRegionBehaviors();

            Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low);
            RegisterFrameworkExceptionTypes();

            Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low);
            Shell = CreateShell();
            if (Shell != null)
            {
                Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low);
                RegionManager.SetRegionManager(Shell, Container.Resolve <IRegionManager>());

                Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low);
                RegionManager.UpdateRegions();

                Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low);
                InitializeShell();
            }

            if (Container.CanResolve <IModuleManager>())
            {
                Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low);
                InitializeModules();
            }

            Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low);
        }