public CommandExecutionResult ExecuteCommand(string command) { using (Logger.CreateCallstackAndLock()) { CheckOpened(); WriteCommand(string.Format(CultureInfo.InvariantCulture, "call {0}", command)); CommandExecutionResult result = new CommandExecutionResult(); using (ElementLogReader groupReader = _reader.WaitForGroupAndCreateLogReader()) using (ElementLogReader callReader = groupReader.WaitForNonEmptyElementAndCreateLogReader("call", LogReadFlags.ThrowFailures)) { while (callReader.Read(0)) { string value; if (callReader.GetEmptyElementValue("output", out value)) { result.Output = value; } if (callReader.GetEmptyElementValue("erroroutput", out value)) { result.ErrorOutput = value; } } groupReader.ReadToEnd(LogReadFlags.ThrowFailures); } return result; } }
public CommandExecutionResult ExecuteCommand(string command) { using (Logger.CreateCallstackAndLock()) { CheckOpened(); WriteCommand(string.Format(CultureInfo.InvariantCulture, "call {0}", command)); CommandExecutionResult result = new CommandExecutionResult(); // registering before creating group reader, so that // it is still registered, when group reader is read to the end in it's .Dispose(); using (RegisterOperationResult(result)) using (ElementLogReader groupReader = _reader.WaitForGroupAndCreateLogReader()) using (ElementLogReader callReader = groupReader.WaitForNonEmptyElementAndCreateLogReader("call", LogReadFlags.ThrowFailures)) { while (callReader.Read(0)) { string value; if (callReader.GetEmptyElementValue("output", out value)) { result.Output = value; } if (callReader.GetEmptyElementValue("erroroutput", out value)) { result.ErrorOutput = value; } if (callReader.GetEmptyElementValue("exitcode", out value)) { result.ExitCode = int.Parse(value, CultureInfo.InvariantCulture); } } } return result; } }