Ejemplo n.º 1
0
        public IEnumerable <Type> GetQueryAndResultTypes()
        {
            var queryTypes  = CoreBootstrap.GetQueryTypes().Select(q => q.QueryType);
            var resultTypes = CoreBootstrap.GetQueryTypes().Select(q => q.ResultType).Distinct();

            return(queryTypes.Concat(resultTypes));
        }
Ejemplo n.º 2
0
        private static Container Bootstrap()
        {
            // Create the container as usual.
            var container = new Container();

            container.Options.DefaultScopedLifestyle       = new AsyncScopedLifestyle();
            container.Options.AllowOverridingRegistrations = true;

            CoreBootstrap.Bootstrap(container);

            container.Register <IGetActivatedWindow, ApplicationActivatedWindow>(Lifestyle.Singleton);
            // container.Register<ICurrentWindow, PInvokeActivatedWindow>(Lifestyle.Singleton);

            // Views
            container.Register <MainWindow>();
            container.Register <IEntityEditorView <ApplicationSettings>, SettingsWindow>();

            // View models
            container.Register <IMainWindowViewModel, MainWindowViewModel>(Lifestyle.Scoped);
            container.Register <IProjectCollectionViewModel, ProjectCollectionViewModel>(Lifestyle.Scoped);
            container.Register <IStatusViewModel, StatusViewModel>(Lifestyle.Scoped);
            container.Register <IEntityEditorViewModel <ApplicationSettings>, ApplicationSettingsViewModel>(Lifestyle.Scoped);

            // not sure if both are the same instance.
            container.Register <IStatusReadModel, StatusModel>(Lifestyle.Singleton);
            container.Register <IStatusFullModel, StatusModel>(Lifestyle.Singleton);
            container.RegisterDecorator <IStatusFullModel, StatusModelLogDecorator>(Lifestyle.Singleton);

            container.RegisterSingleton <IModelEditor, EditModelInDialog>();

            container.RegisterSingleton <IReadOnlyConfigurationService, FileBasedConfigurationService>();
            container.RegisterSingleton <IConfigurationService, FileBasedConfigurationService>();
            container.RegisterDecorator <IConfigurationService, CacheConfigurationServiceDecorator>(Lifestyle.Singleton);
            container.RegisterDecorator <IConfigurationService, ConcurrentConfigurationServiceDecorator>(Lifestyle.Singleton);

            container.Register <IConfigFilenameProvider, AppConfigFilenameProvider>(Lifestyle.Singleton);
            container.RegisterDecorator <IConfigFilenameProvider, VerifyAndFixFilenameDecorator>(Lifestyle.Singleton);
            container.RegisterDecorator <IConfigFilenameProvider, UpdateStatusModelDecorator>(Lifestyle.Singleton);

            container.Register <IProjectViewModelFactory, ProjectViewModelFactory>(Lifestyle.Scoped);

            container.Register <IUserInterfaceSynchronizationContextProvider, UserInterfaceSynchronizationContextProvider>(Lifestyle.Singleton);

            RegisterPlugins(container);

            RegisterUserInterfaceDependencies(container);

            RegisterDelay(container);

            container.RegisterSingleton <DispatcherObject, App>();
            container.RegisterSingleton <Application, App>();

            container.Verify(VerificationOption.VerifyAndDiagnose);

            return(container);
        }
Ejemplo n.º 3
0
        public void Bootstrap_ResultsInValidContainerTest()
        {
            // arrange
            var container = new Container();

            CoreBootstrap.Bootstrap(container);

            // act
            Action act = () => container.Verify();

            // assert
            act.Should().NotThrow();
        }
Ejemplo n.º 4
0
        public void Init()
        {
            Container.Options.DefaultScopedLifestyle       = new AsyncScopedLifestyle();
            Container.Options.AllowOverridingRegistrations = true;

            CoreBootstrap.Bootstrap(Container);

            Container.RegisterInstance <IConsole>(ConsoleAdapter.Instance);

            RegisterDefaultOptions();

            Container.RegisterDecorator(
                typeof(ICommandHandler <>),
                typeof(SetRootDirectoryCommandHandlerDecorator <>),
                Lifestyle.Scoped,
                ctx => typeof(IDirectoryProperty).IsAssignableFrom(ctx.ServiceType.GetGenericArguments()[0]));

            Container.RegisterDecorator(
                typeof(ICommandHandler <>),
                typeof(HoldConsoleCommandHandlerDecorator <>),
                Lifestyle.Scoped,
                ctx => Container.GetInstance <IHoldOnExitOption>().HoldOnExit);

            Container.RegisterDecorator(
                typeof(ICommandHandler <>),
                typeof(WriteExceptionToConsoleCommandHandlerDecorator <>),
                Lifestyle.Scoped);

            Container.RegisterDecorator(
                typeof(IFileSystem),
                typeof(DryRunFileSystemDecorator),
                Lifestyle.Scoped,
                ctx => Container.GetInstance <IDryRunOption>().IsDryRun);

            Container.RegisterDecorator(
                typeof(IFileSystem),
                typeof(VerboseFileSystemDecorator),
                Lifestyle.Scoped,
                ctx => Container.GetInstance <IVerboseOption>().Level != VerboseLevel.Disabled);

            Container.RegisterDecorator(
                typeof(IFileSearch),
                typeof(VerboseFileSearchDecorator),
                Lifestyle.Scoped,
                ctx => Container.GetInstance <IVerboseOption>().Level != VerboseLevel.Disabled);

            Container.Register <IRootDirSanitizer, RemoveRootDirSanitizer>(Lifestyle.Scoped);
            Container.Register <IHoldConsole, HoldConsole>(Lifestyle.Singleton);

            RegisterPlugins();
        }
Ejemplo n.º 5
0
 public IEnumerable <Type> GetCommandTypes() => CoreBootstrap.GetCommandTypes();