コード例 #1
0
ファイル: ContainerConfig.cs プロジェクト: akobr/texo.ui
        public static void RegisterEngineServices(this SimpleIoc container, TexoEngineBuilder builder)
        {
            ITexoEngineServiceLocator engineServiceLocator = builder.GetServiceLocator();

            container.Register(engineServiceLocator.MessageBus);
            container.Register(engineServiceLocator.MessageBusRegister);
            container.Register(engineServiceLocator.Logger);
            container.Register(engineServiceLocator.Environment);
            container.Register(engineServiceLocator.Setting);
            container.Register <IFactory <IInputHistoryService> >(() => new DelegatedFactory <IInputHistoryService>(engineServiceLocator.History));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: akobr/texo.ui
        private static void Startup()
        {
            SimpleIoc container = new SimpleIoc();

            container.Register <ServiceMessageBus>();
            container.Register <IServiceMessageBus>(() => container.GetInstance <ServiceMessageBus>());
            container.Register <IServiceMessageBusRegister>(() => container.GetInstance <ServiceMessageBus>());

            container.Register <ILogService, DebugLogService>();
            container.Register <IInputParseService, InputParseService>();
            container.Register <IInputEvaluationService, InputEvaluationService>();
            container.Register <IEnvironmentService, EnvironmentService>();
            container.Register <ISettingService, SettingService>();
            container.Register <ICommandManagementService, SingletonCommandManagementService>();
            container.Register <IResultProcessingService, ResultProcessingService>();
            container.Register <IMarkdownService, MarkdownService>();
            container.Register <IConsoleRenderService, ConsoleMarkdownRenderService>();
            container.Register <ConsoleViewService>();
            container.Register <IViewService>(() => container.GetInstance <ConsoleViewService>());
            container.Register <IPromptableViewService>(() => container.GetInstance <ConsoleViewService>());

            // PowerShell Fallback
            container.Register <IPowerShellResultBuilder, PowerShellResultMarkdownBuilder>();
            container.Register <IFallbackService, PowerShellFallbackService>();

            // Core commands
            container.Register <CurrentDirectoryCommand>();
            container.Register <TexoCommand>();
            container.Register <HelpCommand>();
            container.Register <ClearCommand>();

            // Simple commands
            container.Register <ReferenceCheckCommand>();
            container.Register <CommandLineCommand>();

            // File manager
            container.Register <ISerialisationService, JsonSerialisationService>();
            container.Register <IStageService, StageService>();
            container.Register <IStashService, StashService>();
            container.Register <FileManagerCommand>();

            // Nuget manager
            container.Register <IProjectManagementService, ProjectManagementService>();
            container.Register <IPackageManagementService, PackageManagementService>();
            container.Register <IConfigManagementService, ConfigManagementService>();
            container.Register <ISourceManagementService, SourceManagementService>();
            container.Register <IManagementService, ManagementService>();
            container.Register <Commands.NugetManager.Stage.IStageService, Commands.NugetManager.Stage.StageService>();
            container.Register <NugetManagerCommand>();

            CommandFactory commandFactory = new CommandFactory();

            container.Register <ITexoFactory <object, string> >(() => commandFactory);
            commandFactory.Register(CommandKeys.CURRENT_DIRECTORY, () => container.GetInstance <CurrentDirectoryCommand>());
            commandFactory.Register(CommandKeys.TEXO, () => container.GetInstance <TexoCommand>());
            commandFactory.Register(CommandKeys.HELP, container.GetInstance <HelpCommand>);
            commandFactory.Register(CommandKeys.CLEAR, container.GetInstance <ClearCommand>);
            commandFactory.Register(ReferenceCheckConstants.REF_CHECK, () => container.GetInstance <ReferenceCheckCommand>());
            commandFactory.Register("command-line", () => container.GetInstance <CommandLineCommand>());
            commandFactory.Register("file-manager", () => container.GetInstance <FileManagerCommand>());
            commandFactory.Register("nuget-manager", () => container.GetInstance <NugetManagerCommand>());

            ServiceMessageBus messageBus = container.GetInstance <ServiceMessageBus>();

            var engineBuilder = new TexoEngineBuilder(messageBus, messageBus)
                                .WithLogService(container.GetInstance <ILogService>())
                                .WithInputParseService(container.GetInstance <IInputParseService>())
                                .WithInputEvaluationService(container.GetInstance <IInputEvaluationService>())
                                .WithEnvironmentService(container.GetInstance <IEnvironmentService>())
                                .WithSettingService(container.GetInstance <ISettingService>())
                                .WithCommandManagementService(container.GetInstance <ICommandManagementService>())
                                .WithResultProcessingService(container.GetInstance <IResultProcessingService>())
                                .WithFallbackService(container.GetInstance <IFallbackService>());

            var locator = engineBuilder.GetServiceLocator();

            container.Register(locator.ActionProvider);
            container.Register(locator.ActionRegister);

            engine = engineBuilder.Build(commandFactory, container.GetInstance <IViewService>());

            var config = TexoConfiguration.CreateDefault().ToBuilder();

            config.Runtime.Commands.Add(ReferenceCheckCommand.BuildConfiguration());
            config.Runtime.Commands.Add(CommandLineCommand.BuildConfiguration());
            config.Runtime.Commands.Add(FileManagerBuilder.BuildCommand());
            config.Runtime.Commands.Add(NugetManagerBuilder.BuildCommand());

            engine.Initialise(config.ToImmutable());
        }