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()); }