Exemplo n.º 1
0
Arquivo: Task.cs Projeto: vorov2/slot
        private void InternalRun()
        {
            running = true;
            Write($"Task {Name}");
            var errors = 0;
            var idx    = 0;

            foreach (var s in Steps)
            {
                if (s.Properties != null && DefaultProperties != null)
                {
                    s.Properties = s.Properties.MergeWith(DefaultProperties);
                }
                else if (DefaultProperties != null)
                {
                    s.Properties = DefaultProperties.Clone();
                }

                Write($"{++idx}. Step {s.Name}");

                var res = false;
                currentStep = s.Start(Output);
                var tt = TT.Task.Run(() => res = currentStep.Wait());
                tt.Wait();

                if (!res)
                {
                    errors++;
                }

                if (!res && Behavior == TaskBehavior.FailFirst)
                {
                    Write($"Task terminated ({Behavior}).");
                    break;
                }
            }

            Write($"Task completed. Errors: {errors}. Passed: {Steps.Count-errors}");
            running = false;
        }