(ProcessStartInfo startInfo)
| 68 | } |
| 69 | |
| 70 | public static ExitedProcess RunProcess(ProcessStartInfo startInfo) |
| 71 | { |
| 72 | startInfo.RedirectStandardOutput = true; |
| 73 | startInfo.RedirectStandardError = true; |
| 74 | |
| 75 | StringBuilder outputBuilder = new StringBuilder(); |
| 76 | Process process = new Process |
| 77 | { |
| 78 | StartInfo = startInfo |
| 79 | }; |
| 80 | DataReceivedEventHandler outputHandler = new DataReceivedEventHandler( |
| 81 | delegate (object sender, DataReceivedEventArgs e) { |
| 82 | outputBuilder.AppendLine(e.Data); |
| 83 | } |
| 84 | ); |
| 85 | |
| 86 | process.OutputDataReceived += outputHandler; |
| 87 | process.ErrorDataReceived += outputHandler; |
| 88 | |
| 89 | process.Start(); |
| 90 | process.BeginOutputReadLine(); |
| 91 | process.BeginErrorReadLine(); |
| 92 | process.WaitForExit(); |
| 93 | process.CancelOutputRead(); |
| 94 | process.CancelErrorRead(); |
| 95 | |
| 96 | return new ExitedProcess |
| 97 | { |
| 98 | ExitCode = process.ExitCode, |
| 99 | Output = outputBuilder.ToString().Trim() |
| 100 | }; |
| 101 | } |
| 102 | |
| 103 | public static Process RunUnmanagedProcess(ProcessStartInfo startInfo) |
| 104 | { |
no outgoing calls
no test coverage detected