// Respond license questions with the "response". public void CheckAndRespond(System.Diagnostics.Process process, StreamWriter stdin, CommandLine.StreamData data) { if (process.HasExited) { return; } if ((data.data != null && data.text.Contains(Question)) || CommandLine.LineReader.Aggregate(GetBufferedData(0)).text.Contains(Question)) { Flush(); // Ignore I/O exceptions as this could race with the process exiting. try { foreach (byte b in System.Text.Encoding.UTF8.GetBytes( response + System.Environment.NewLine)) { stdin.BaseStream.WriteByte(b); } stdin.BaseStream.Flush(); } catch (System.IO.IOException) { } } }
private void PollQueue() { while (this.activeStreams.Count > 0) { this.queuedItem.WaitOne(); while (this.queue.Count > 0) { CommandLine.StreamData streamData = (CommandLine.StreamData) this.queue.Dequeue(); if (streamData.end) { object obj = this.activeStreams; lock (obj) { this.activeStreams.Remove(streamData.handle); } } if (this.DataReceived != null) { this.DataReceived(streamData); } } } if (this.Complete != null) { this.Complete(); } }
public void AggregateLine(Process process, StreamWriter stdin, CommandLine.StreamData data) { if (this.DataHandler != null) { this.DataHandler(process, stdin, data); } bool flag = false; if (data.data != null) { data.text = data.text.Replace("\r\n", "\n").Replace("\r", "\n"); List <CommandLine.StreamData> list = this.GetBufferedData(data.handle); list.Add(data); bool flag2 = false; while (!flag2) { List <CommandLine.StreamData> list2 = new List <CommandLine.StreamData>(); int num = 0; int count = list.Count; flag2 = true; foreach (CommandLine.StreamData current in list) { bool flag3 = data.end && ++num == count; list2.Add(current); int num2 = current.text.Length; if (!flag3) { num2 = current.text.IndexOf("\n"); if (num2 < 0) { continue; } list2.Remove(current); } CommandLine.StreamData streamData = CommandLine.LineReader.Aggregate(list2); list2.Clear(); if (!flag3) { CommandLine.StreamData expr_10C = streamData; expr_10C.text += current.text.Substring(0, num2 + 1); list2.Add(new CommandLine.StreamData(data.handle, current.text.Substring(num2 + 1), current.data, false)); flag2 = false; } if (this.LineHandler != null) { this.LineHandler(process, stdin, streamData); } flag = true; } list = list2; } this.streamDataByHandle[data.handle] = list; } if (!flag && this.LineHandler != null) { this.LineHandler(process, stdin, CommandLine.StreamData.Empty); } }
/// <summary> /// Called from RunCommandLine() tool to report the output of the currently /// executing commmand. /// </summary> /// <param name="process">Executing process.</param> /// <param name="stdin">Standard input stream.</param> /// <param name="data">Data read from the standard output or error streams.</param> private void CommandLineIOHandler(Process process, StreamWriter stdin, CommandLine.StreamData data) { if (process.HasExited || data.data == null) { return; } // Count lines in stdout. if (data.handle == 0) { linesReported += CountLines(data.text); } // Enqueue data for the text view. textQueue.Enqueue(System.Text.Encoding.UTF8.GetString(data.data)); }
private void CommandLineIOHandler(Process process, StreamWriter stdin, CommandLine.StreamData data) { if (process.HasExited || data.data == null) { return; } if (data.handle == 0) { this.linesReported += this.CountLines(data.text); } string @string = Encoding.UTF8.GetString(data.data); this.textQueue.Enqueue(@string); string[] array = CommandLine.SplitLines(@string); for (int i = 0; i < array.Length; i++) { string message = array[i]; this.logger.Log(message, LogLevel.Verbose); } }
/// <summary> /// Called from RunCommandLine() tool to report the output of the currently /// executing commmand. /// </summary> /// <param name="process">Executing process.</param> /// <param name="stdin">Standard input stream.</param> /// <param name="data">Data read from the standard output or error streams.</param> private void CommandLineIOHandler(Process process, StreamWriter stdin, CommandLine.StreamData data) { if (process.HasExited || data.data == null) { return; } // Count lines in stdout. if (data.handle == 0) { linesReported += CountLines(data.text); } // Enqueue data for the text view. var newLines = System.Text.Encoding.UTF8.GetString(data.data); textQueue.Enqueue(newLines); // Write to the logger. foreach (var line in CommandLine.SplitLines(newLines)) { logger.Log(line, level: LogLevel.Verbose); } }
private void HandleRead(CommandLine.StreamData streamData) { this.queue.Enqueue(streamData); this.queuedItem.Set(); }