internal void Complete(string output, string failures, int exitCode, ExitCodeChecker exitCodeChecker, bool failIfAnyErrors) { this.OutputText = output; this.ErrorText = failures; this.ExitCode = exitCode; if ((failIfAnyErrors && !String.IsNullOrWhiteSpace(this.ErrorText)) || (exitCodeChecker != null && !exitCodeChecker(this.ExitCode))) { this.Success = false; } }
/// <summary> /// Builds a runner to execute /// </summary> /// <param name="workingDir">The working directory (default=<c>null</c> - not set in process)</param> /// <param name="displayStyle">Either <see cref="eDisplayStyle.Visible"/> to show a cmd window, or <see cref="eDisplayStyle.Hidden"/> to run with no cmd window (default=<see cref="eDisplayStyle.Hidden"/>)</param> /// <param name="timeout">How long to wait before killing the process. (default=<see cref="ProcRunner.kNoTimeout"/>)</param> /// <param name="failIfAnyErrors">Makes it so the <see cref="ProcRunResults"/> is a failure result if any redirected error text is received (default=<c>true</c>)</param> /// <param name="exitCodeChecker">A function to run that validates the exit code of the process (default=<c>null</c> - Makes 0 success and anything else failure)</param> /// <returns>A <see cref="ProcRunner"/> built with the specified settings</returns> public ProcRunner BuildRunner(string workingDir = null, eDisplayStyle displayStyle = eDisplayStyle.Hidden, int timeout = ProcRunner.kNoTimeout, bool failIfAnyErrors = true, ExitCodeChecker exitCodeChecker = null) { return(new ProcRunner(this, workingDir, displayStyle, timeout, failIfAnyErrors, exitCodeChecker)); }
internal ProcRunner(ProcConfiguration owner, string workingDir, eDisplayStyle displayStyle, int timeout, bool failIfAnyErrors, ExitCodeChecker exitCodeChecker) { this.Configuration = owner; this.WorkingDir = workingDir; this.DisplayStyle = displayStyle; this.Timeout = timeout; this.FailIfAnyErrors = failIfAnyErrors; this.ExitCodeValidator = exitCodeChecker; }