Ejemplo n.º 1
0
        public ReplServices(FileIO injectedIO = null) // defaults to real io
        {
            // some of the initialization can be heavy, and causes slow startup time for the UI.
            // run it in a background thread so the UI can render immediately.
            requiredInitialization = Task.WhenAll(
                Task.Run(() =>
            {
                this.syntaxHighlighter = new SyntaxHighlighter("Themes/theme.vssettings");
                UserConfigurationLoaded?.Invoke(this, new UserConfiguration
                                                (
                                                    syntaxHighlighter.BackgroundColor,
                                                    syntaxHighlighter.ForegroundColor
                                                ));
                this.codeCompleter = new CodeCompleter();
            }),
                Task.Run(() =>
            {
                this.io               = injectedIO ?? FileIO.RealIO;
                var assemblies        = new DefaultAssemblies(new DotNetAssemblyLocator(() => new Process(), io));
                this.scriptEvaluator  = new ScriptEvaluator(assemblies);
                this.workspaceManager = new WorkspaceManager(assemblies);
            })
                );
            commandInitialization = Task.Run(async() =>
            {
                await requiredInitialization;

                this.commandHandlers = new ICommandHandler[]
                {
                    new ExitCommandHandler(),
                    new HelpCommandHandler(),
                    new AssemblyReferenceCommandHandler(scriptEvaluator, workspaceManager, io),
                    new NugetReferenceCommandHandler(scriptEvaluator, workspaceManager, new NugetPackageInstaller(io)),
                    new EvaluationCommandHandler(scriptEvaluator, workspaceManager, new PrettyPrinter())
                };

                this.savers = new ISessionSaver[]
                {
                    new CSharpSessionSaver(io, workspaceManager),
                    new MarkdownSessionSaver(io),
                };

                this.dataFlowAnalyzer = new DataFlowAnalyzer();
            });
        }
Ejemplo n.º 2
0
        public ReplServices()
        {
            // some of the initialization can be heavy, and causes slow startup time for the UI.
            // run it in a background thread so the UI can render immediately.
            initialization = Task.Run(() =>
            {
                this.syntaxHighlighter = new SyntaxHighlighter("theme.vssettings");
                UserConfigurationLoaded?.Invoke(this, new UserConfiguration
                                                (
                                                    syntaxHighlighter.BackgroundColor,
                                                    syntaxHighlighter.ForegroundColor
                                                ));

                this.scriptEvaluator  = new ScriptEvaluator();
                this.codeCompleter    = new CodeCompleter();
                this.workspaceManager = new WorkspaceManager();
            });
            // nuget service has filesystem IO, so it takes a lot of time to resolve
            // run it separate from the other services so the other services aren't blocked.
            nugetInitialization = Task.Run(() =>
            {
                this.nugetResolver = new NugetPackageResolver();
            });
        }