Пример #1
0
 public InputTreeUpdatedMessage(
     TexoConfiguration configuration,
     InputTree inputTree)
 {
     Configuration = configuration;
     InputTree     = inputTree;
 }
Пример #2
0
        public static Task InitialiseWithCommandsAsync(this TexoEngine engine, SimpleIoc container)
        {
            TexoConfiguration.Builder configuration = TexoConfiguration.CreateDefault().ToBuilder();

            string solutionFile = container.GetInstance <ISolutionPathProvider>().GetPath();

            if (!string.IsNullOrEmpty(solutionFile))
            {
                configuration.Environment.Variables.Add(VsVariableNames.SOLUTION_FILE, solutionFile);
            }

            configuration.Runtime.Commands.AddRange(new[] {
                ReferenceCheckCommand.BuildConfiguration(),
                CommandLineCommand.BuildConfiguration(),
                FileManagerBuilder.BuildCommand(),
                NugetManagerBuilder.BuildCommand(),
                CalcCommand.BuildConfiguration(),
                //ClipboardBuilder.BuildCommand(),
                FunctionsBuilder.BuildCommand(),
                CodeBaseSearchBuilder.BuildCommand(),
                SpinSportBuilder.BuildCommand()
            });

            return(engine.InitialiseAsync(configuration.ToImmutable()));
        }
Пример #3
0
        async void IMessageBusRecipient <ISettingUpdatedMessage> .ProcessMessage(ISettingUpdatedMessage message)
        {
            try
            {
                configuration = message.Configuration;
                tree          = await Task.Run(() => BuildInputTree(message.Configuration));

                if (configuration != message.Configuration)
                {
                    return;
                }

                messageBus.Send <IInputTreeUpdatedMessage>(new InputTreeUpdatedMessage(configuration, tree));
            }
            catch (System.Exception exception)
            {
                logger.Error("An unknown error happend during input tree build.", exception);
            }
        }
Пример #4
0
        private InputTree BuildInputTree(TexoConfiguration fromConfiguration)
        {
            IInputTreeBuilder treeBuilder = new InputTreeBuilder(logger);

            return(treeBuilder.Build(fromConfiguration.Runtime.Commands, fromConfiguration.Runtime.DefaultCommand));
        }
Пример #5
0
        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());
        }
Пример #6
0
 internal Builder(TexoConfiguration immutable)
 {
     Runtime     = immutable.runtime.ToBuilder();
     Environment = immutable.environment.ToBuilder();
     Ui          = immutable.ui.ToBuilder();
 }
Пример #7
0
 void IMessageBusRecipient <ISettingUpdatedMessage> .ProcessMessage(ISettingUpdatedMessage message)
 {
     configuration = message.Configuration;
 }
Пример #8
0
 public void SetConfiguration(TexoConfiguration configuration)
 {
     this.configuration = configuration;
 }