Ejemplo n.º 1
0
        protected override async Task <object> InitializeToolWindowAsync(Type toolWindowType, int id, CancellationToken cancellationToken)
        {
            // Perform as much work as possible in this method which is being run on a background thread.
            // The object returned from this method is passed into the constructor of the SampleToolWindow
            var container = new SimpleIoc();

            container.RegisterServices();

            container.Register <IDteProvider>(() => new DteProvider(DTE));

            var engineBuilder = new TexoEngineBuilder()
                                .WithLogService(new DebugLogService());

            container.RegisterEngineServices(engineBuilder);
            engineBuilder.WithFallbackService(container.GetInstance <IFallbackService>());

            var commandFactory = new CommandFactory();

            commandFactory.RegisterCommands(container);
            container.RegisterCommandFactory(commandFactory);

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

            var messageBus = container.GetInstance <IServiceMessageBus>();

            container.RegisterWithMessageBus();
            container.RegisterIntellisense();

            var environment = container.GetInstance <IEnvironmentService>();

            container.Register <ISolutionOpenStrategy>(() => new CurrentSolutionOpenStrategy(ComponentModel));

            Context = new ExtensionContext(
                DTE,
                JoinableTaskFactory,
                texoEngine,
                environment,
                messageBus);

            // Register of variable strategies
            environment.RegisterVariableStrategy(VsVariableNames.SOLUTION_FILE, new SolutionFileStrategy(environment));
            environment.RegisterVariableStrategy(VsVariableNames.SOLUTION_DIRECTORY, new SolutionDirectoryStrategy(environment));

            // Register of actions
            texoEngine.RegisterAction(new SimpleActionFactory <UriOpenAction>(), ActionNames.URI);
            texoEngine.RegisterAction(new PathOpenActionFactory(Context), ActionNames.PATH_OPEN, ActionNames.PATH);
            texoEngine.RegisterAction(new InputSetActionFactory(container.GetInstance <IViewService>()), ActionNames.INPUT_SET, ActionNames.INPUT);

            await texoEngine.InitialiseWithCommandsAsync(container);

            texoEngine.Start();
            return(Context);
        }
Ejemplo n.º 2
0
        private static void StartUp()
        {
            SimpleIoc container = new SimpleIoc();

            container.RegisterServices();

            TexoEngineBuilder engineBuilder = new TexoEngineBuilder();

            container.RegisterEngineServices(engineBuilder);

            CommandFactory commandFactory = new CommandFactory();

            commandFactory.RegisterCommands(container);
            container.RegisterCommandFactory(commandFactory);

            engineBuilder.WithFallbackService(container.GetInstance <IFallbackService>());
            TexoEngine = engineBuilder.Build(commandFactory, container.GetInstance <IViewService>());
            TexoEngine.InitialiseWithCommands();
            TexoEngine.Start();
        }
Ejemplo n.º 3
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            SimpleIoc container = new SimpleIoc();

            container.RegisterServices();

            TexoEngineBuilder engineBuilder =
                new TexoEngineBuilder()
                .WithLogService(new DebugLogService());

            container.RegisterEngineServices(engineBuilder);

            CommandFactory commandFactory = new CommandFactory();

            commandFactory.RegisterCommands(container);
            container.RegisterCommandFactory(commandFactory);

            engineBuilder.WithFallbackService(container.GetInstance <IFallbackService>());
            TexoEngine = engineBuilder.Build(commandFactory, container.GetInstance <IViewService>());
            TexoEngine.RegisterAction(new SimpleActionFactory <UriOpenAction>(), ActionNames.URI);
            TexoEngine.RegisterAction(new PathOpenActionFactory(container.GetInstance <IExecutor>()), ActionNames.PATH_OPEN, ActionNames.PATH);
            TexoEngine.RegisterAction(new InputSetActionFactory(container.GetInstance <IViewService>()), ActionNames.INPUT_SET, ActionNames.INPUT);

            ServiceMessageBus = container.GetInstance <IServiceMessageBus>();
            container.RegisterWithMessageBus();
            container.RegisterIntellisense();

            await TexoEngine.InitialiseWithCommandsAsync();

            TexoEngine.Start();

            //var searchService = container.GetInstance<ICodeBaseSearchService>();
            //await searchService.PreLoadAsync();
            //await searchService.LoadAsync();
        }
Ejemplo n.º 4
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());
        }