예제 #1
0
        void WritePlainText(ProcessOutputSource source, string text)
        {
            switch (source)
            {
            case ProcessOutputSource.Debug:
                debugTarget(text);
                break;

            case ProcessOutputSource.StdOut:
                outputTarget(text);
                break;

            case ProcessOutputSource.StdErr:
                errorTarget(text);
                break;
            }
        }
예제 #2
0
        void ProcessMessage(ProcessOutputSource source, string message)
        {
            try
            {
                message = message.Trim().TrimStart('[').Replace("\r", "").Replace("\n", "");

                var element = XElement.Parse("<" + message + "/>");
                var name    = element.Name.LocalName;
                var values  = element.Attributes().ToDictionary(s => s.Name.LocalName, s => Encoding.UTF8.GetString(Convert.FromBase64String(s.Value)), StringComparer.OrdinalIgnoreCase);
                serviceMessage(new ServiceMessage(name, values));
            }
            catch
            {
                serviceMessage(new ServiceMessage("stdout-warning", null));
                output(source, $"Could not parse '{ServiceMessage.ServiceMessageLabel}[{message}]'");
                serviceMessage(new ServiceMessage("stdout-default", null));
            }
        }
예제 #3
0
        void WritePlainText(ProcessOutputSource source, string text)
        {
            using (log.WithinBlock(logContext))
            {
                switch (source)
                {
                case ProcessOutputSource.Debug:
                    debugTarget(text);
                    break;

                case ProcessOutputSource.StdOut:
                    outputTarget(text);
                    break;

                case ProcessOutputSource.StdErr:
                    errorTarget(text);
                    break;
                }
            }
        }
예제 #4
0
        public void Append(ProcessOutputSource source, string line)
        {
            if (lastSource != source)
            {
                Finish();
            }

            lastSource = source;

            for (var i = 0; i < line.Length; i++)
            {
                var c = line[i];

                switch (state)
                {
                case State.Default:
                    if (c == '\r')
                    {
                    }
                    else if (c == '\n')
                    {
                        Flush(output);
                    }
                    else if (c == '#')
                    {
                        state = State.PossibleMessage;
                        buffer.Append(c);
                    }
                    else
                    {
                        buffer.Append(c);
                    }
                    break;

                case State.PossibleMessage:
                    buffer.Append(c);
                    var progress = buffer.ToString();
                    if (ServiceMessage.ServiceMessageLabel == progress)
                    {
                        state = State.InMessage;
                        buffer.Clear();
                    }
                    else if (!ServiceMessage.ServiceMessageLabel.StartsWith(progress))
                    {
                        state = State.Default;
                    }
                    break;

                case State.InMessage:
                    if (c == ']')
                    {
                        Flush(ProcessMessage);
                        state = State.Default;
                    }
                    else
                    {
                        buffer.Append(c);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #5
0
 public void Write(ProcessOutputSource source, string text)
 {
     parser.Append(source, text);
     parser.Finish();
 }
예제 #6
0
 public ProcessOutput(ProcessOutputSource source, string text, DateTimeOffset occurred)
 {
     this.source   = source;
     this.text     = text;
     this.occurred = occurred;
 }
예제 #7
0
 public ProcessOutput(ProcessOutputSource source, string text)
     : this(source, text, DateTimeOffset.UtcNow)
 {
 }