Beispiel #1
0
        private static ScriptServices BuildScriptServices(InOutConsole console)
        {
            var logConfiguration = new LoggerConfigurator(LogLevel.Info);
            logConfiguration.Configure(console);
            var logger = logConfiguration.GetLogger();

            var initializationServices = new InitializationServices(logger);

            initializationServices.GetAppDomainAssemblyResolver().Initialize();

            var scriptServicesBuilder = new ScriptServicesBuilder(console, logger, null, null, initializationServices)
                .Repl(true);

            scriptServicesBuilder.LoadModules("");

            var scriptServices = scriptServicesBuilder.Build();

            initializationServices.GetInstallationProvider().Initialize();

            scriptServices.Repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
            return scriptServices;
        }
Beispiel #2
0
        private static void RunRepl(TextReader input, TextWriter output)
        {
            var vt = new VirtualTerminal(input, output);

            var console = new InOutConsole(vt);

            var scriptServices = BuildScriptServices(console);

            while (true)
            {
                string line = vt.ReadLine(">");

                if (line == "q")
                {
                    scriptServices.Repl.Terminate();
                    break;
                }

                if (!string.IsNullOrWhiteSpace(line))
                {
                    vt.RecordHistoryLine(line);
                }

                scriptServices.Repl.Execute(line);
            }
        }