Beispiel #1
0
 /// <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)
 {
     // Note: ignoring process.HasExited to print errors that were emitted during shutdown.
     if (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));
 }
Beispiel #2
0
        // Respond license questions with the "response".
        public void CheckAndRespond(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) {
                }
            }
        }