示例#1
0
        /// <summary>Sends notification signal to the host.</summary>
        /// <param name="hostSignal">The signal to send.</param>
        public void SendSignal(HostSignal hostSignal)
        {
            switch (hostSignal)
            {
            case HostSignal.BeforeAnythingElse:
                diagnoser?.BeforeAnythingElse(diagnoserActionParameters);
                WriteLine(Engine.Signals.BeforeAnythingElse);
                break;

            case HostSignal.AfterGlobalSetup:
                diagnoser?.AfterGlobalSetup(diagnoserActionParameters);
                WriteLine(Engine.Signals.AfterGlobalSetup);
                break;

            case HostSignal.BeforeMainRun:
                diagnoser?.BeforeMainRun(diagnoserActionParameters);
                WriteLine(Engine.Signals.BeforeMainRun);
                break;

            case HostSignal.BeforeGlobalCleanup:
                diagnoser?.BeforeGlobalCleanup(diagnoserActionParameters);
                WriteLine(Engine.Signals.BeforeGlobalCleanup);
                break;

            case HostSignal.AfterAnythingElse:
                WriteLine(Engine.Signals.AfterAnythingElse);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(hostSignal), hostSignal, null);
            }
        }
        internal void ProcessInput()
        {
            string line;

            while ((line = process.StandardOutput.ReadLine()) != null)
            {
                logger.WriteLine(LogKind.Default, line);

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (!line.StartsWith("//"))
                {
                    LinesWithResults.Add(line);
                }
                else if (line == Engine.Signals.BeforeAnythingElse)
                {
                    diagnoser?.BeforeAnythingElse(diagnoserActionParameters);
                }
                else if (line == Engine.Signals.AfterGlobalSetup)
                {
                    diagnoser?.AfterGlobalSetup(diagnoserActionParameters);
                }
                else if (line == Engine.Signals.BeforeMainRun)
                {
                    diagnoser?.BeforeMainRun(diagnoserActionParameters);
                }
                else if (line == Engine.Signals.BeforeGlobalCleanup)
                {
                    diagnoser?.BeforeGlobalCleanup();
                }
                else if (line == Engine.Signals.AfterAnythingElse)
                {
                    // TODO: notify AfterAnythingElse
                }
                else
                {
                    LinesWithExtraOutput.Add(line);
                }
            }
        }