Ejemplo n.º 1
0
        public ScriptServices Build()
        {
            var defaultExecutorType = typeof(ScriptExecutor);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor))
                ? (Type)Overrides[typeof(IScriptExecutor)]
                : defaultExecutorType;

            var defaultReplType = typeof(Repl);

            _replType = Overrides.ContainsKey(typeof(IRepl)) ? (Type)Overrides[typeof(IRepl)] : defaultReplType;

            _scriptEngineType = (Type)Overrides[typeof(IScriptEngine)];

            var initDirectoryCatalog = _scriptName != null || _repl;

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(
                    _logger,
                    Overrides,
                    ConsoleInstance,
                    _scriptEngineType,
                    _scriptExecutorType,
                    _replType,
                    initDirectoryCatalog,
                    InitializationServices,
                    _scriptName);
            }

            return(_runtimeServices.GetScriptServices());
        }
Ejemplo n.º 2
0
        public ScriptServices Build(IEnumerable <Assembly> applicationAssemblies)
        {
            var defaultExecutorType = typeof(ScriptExecutor);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor))
                ? (Type)Overrides[typeof(IScriptExecutor)]
                : defaultExecutorType;

            var defaultReplType = typeof(Repl);

            _replType = Overrides.ContainsKey(typeof(IRepl)) ? (Type)Overrides[typeof(IRepl)] : defaultReplType;

            //todo: this hardcodes the engine for now
            var defaultEngineType = _repl ? typeof(CSharpReplEngine) : typeof(CSharpScriptEngine);

            _scriptEngineType = Overrides.ContainsKey(typeof(IScriptEngine)) ? (Type)Overrides[typeof(IScriptEngine)] : defaultEngineType;

            bool initDirectoryCatalog;

            if (_loadScriptPacks.HasValue)
            {
                initDirectoryCatalog = _loadScriptPacks.Value;
            }
            else
            {
                initDirectoryCatalog = _scriptName != null || _repl;
            }

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(
                    _logProvider,
                    Overrides,
                    ConsoleInstance,
                    _scriptEngineType,
                    _scriptExecutorType,
                    _replType,
                    initDirectoryCatalog,
                    InitializationServices,
                    _scriptName, applicationAssemblies);
            }

            return(_runtimeServices.GetScriptServices());
        }
Ejemplo n.º 3
0
        public ScriptServices Build()
        {
            var defaultExecutorType = _debug ? typeof(DebugScriptExecutor) : typeof(ScriptExecutor);
            var defaultEngineType   = _debug ? typeof(RoslynScriptDebuggerEngine) : typeof(RoslynScriptEngine);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor)) ? (Type)Overrides[typeof(IScriptExecutor)] : defaultExecutorType;
            _scriptEngineType   = Overrides.ContainsKey(typeof(IScriptEngine)) ? (Type)Overrides[typeof(IScriptEngine)] : defaultEngineType;

            var initDirectoryCatalog = _scriptName != null || _repl;

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(_logger, Overrides, LineProcessors, _console,
                                                       _scriptEngineType, _scriptExecutorType,
                                                       initDirectoryCatalog,
                                                       _initializationServices);
            }
            return(_runtimeServices.GetScriptServices());
        }