public void Execute(Script script, Regex procedure_pattern) { var textwriter = new StringWriter(); var wscript = new WScript(script.Path, script.Arguments); wscript.OnEcho += textwriter.WriteLine; if (!_compiler.Compile(wscript, script)) return; var list_procedures = ListProcedures(script, procedure_pattern); if (_compiler.Run(list_procedures.ProcInitialize)) { foreach (var procedure in list_procedures) { if (_compiler.Run(list_procedures.ProcSetup)) { if (_compiler.Run(procedure, true)) { OnSuccess(new ScriptSuccees(script, procedure)); } else { var error = _compiler.Error; if (list_procedures.ProcOnError != null) { list_procedures.ProcOnError.Params = new object[] { procedure.Name, _compiler.Error.ToString() }; if (_compiler.Run(list_procedures.ProcOnError)) error.AddInformation((string)_compiler.Result); } OnError(error); } _compiler.Run(list_procedures.ProcTearDown); } } _compiler.Run(list_procedures.ProcTerminate); } if (list_procedures.Count == 0 && script.Succeed) OnSuccess(new ScriptSuccees(script)); OnInfo(script, textwriter.ToString().CleanEnd()); }
public bool Build(Script script = null) { if (_wscript != null) { _msc_compiler.Reset(); _wscriptEcho.Length = 0; } SetLanguage(script); if (script == null) { _wscript = new WScript(); } else { _wscript = new WScript(script.Path, script.Arguments); } _wscript.OnEcho += (m) => _wscriptEcho.AppendLine(m); _script = script; _msc_compiler.AddObject("WScript", _wscript, false); //_compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n"); if (script != null) { return(Execute(script.GetCode())); } return(true); }
public bool Compile(WScript wscript, Script script = null) { _wscript = wscript; if (_script != null) _compiler.Reset(); _script = script; _compiler.AddObject("WScript", wscript, true); _compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n"); if (script != null) return AddCode(script.GetCode()); return true; }
public bool Compile(WScript wscript, Script script = null) { _wscript = wscript; if (_script != null) { _compiler.Reset(); } _script = script; _compiler.AddObject("WScript", wscript, true); _compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n"); if (script != null) { return(AddCode(script.GetCode())); } return(true); }
public void Execute(Script script, Regex procedure_pattern) { var textwriter = new StringWriter(); var wscript = new WScript(script.Path, script.Arguments); wscript.OnEcho += textwriter.WriteLine; if (!_compiler.Compile(wscript, script)) { return; } var list_procedures = ListProcedures(script, procedure_pattern); if (_compiler.Run(list_procedures.ProcInitialize)) { foreach (var procedure in list_procedures) { if (_compiler.Run(list_procedures.ProcSetup)) { if (_compiler.Run(procedure, true)) { OnSuccess(new ScriptSuccees(script, procedure)); } else { var error = _compiler.Error; if (list_procedures.ProcOnError != null) { list_procedures.ProcOnError.Params = new object[] { procedure.Name, _compiler.Error.ToString() }; if (_compiler.Run(list_procedures.ProcOnError)) { error.AddInformation((string)_compiler.Result); } } OnError(error); } _compiler.Run(list_procedures.ProcTearDown); } } _compiler.Run(list_procedures.ProcTerminate); } if (list_procedures.Count == 0 && script.Succeed) { OnSuccess(new ScriptSuccees(script)); } OnInfo(script, textwriter.ToString().CleanEnd()); }
public bool Build(Script script = null) { if (_wscript != null) { _msc_compiler.Reset(); _wscriptEcho.Length = 0; } SetLanguage(script); if (script == null) { _wscript = new WScript(); } else { _wscript = new WScript(script.Path, script.Arguments); } _wscript.OnEcho += (m) => _wscriptEcho.AppendLine(m); _script = script; _msc_compiler.AddObject("WScript", _wscript, false); //_compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n"); if (script != null) return Execute(script.GetCode()); return true; }