コード例 #1
0
        public override int Execute()
        {
            if (!System.IO.File.Exists(_path))
            {
                Echo($"Script file is not found '{_path}'");
                return(2);
            }

            SystemLogger.SetWriter(this);

            var hostedScript = new HostedScriptEngine();

            hostedScript.DebugController = DebugController;
            hostedScript.CustomConfig    = ScriptFileHelper.CustomConfigPath(_path);
            ScriptFileHelper.OnBeforeScriptRead(hostedScript);
            var source = hostedScript.Loader.FromFile(_path);

            Process process;

            try
            {
                process = hostedScript.CreateProcess(this, source);
            }
            catch (Exception e)
            {
                this.ShowExceptionInfo(e);
                return(1);
            }

            var result = process.Start();

            hostedScript.Dispose();

            ScriptFileHelper.OnAfterScriptExecute(hostedScript);

            return(result);
        }