Ejemplo n.º 1
0
        public static void ReceiveErrorData(this CommandLineInvocationResult result, object sender, DataReceivedEventArgs e)
        {
            if (e.Data is null)
            {
                return;
            }

            result.AddError(e.Data);
        }
Ejemplo n.º 2
0
 public static IEnumerable <string> GetErrorLines(this CommandLineInvocationResult result)
 {
     using (var reader = result.GetErrorReader())
     {
         while (reader.ReadLineIsNotEnd(out var line))
         {
             yield return(line);
         }
     }
 }
        public static CommandLineInvocationResult Run(CommandLineInvocation invocation)
        {
            var result = new CommandLineInvocationResult();

            void ReceiveOutputData(object sender, DataReceivedEventArgs e)
            {
                invocation.ReceiveOutputData(sender, e);

                result.ReceiveOutputData(sender, e);
            }

            void ReceiveErrorData(object sender, DataReceivedEventArgs e)
            {
                invocation.ReceiveErrorData(sender, e);

                result.ReceiveErrorData(sender, e);
            }

            result.ExitCode = CommandLineInvocationRunner.Run(invocation.Command, invocation.Arguments, ReceiveOutputData, ReceiveErrorData);

            return(result);
        }
Ejemplo n.º 4
0
        public static StringReader GetErrorReader(this CommandLineInvocationResult result)
        {
            var reader = new StringReader(result.GetErrorText());

            return(reader);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Trims the output text (including any ending \r\n from the output).
        /// </summary>
        public static string GetOutputTextTrimmed(this CommandLineInvocationResult result)
        {
            var output = result.GetOutputText().Trim();

            return(output);
        }