Пример #1
0
 public override void Flow(IColorable connection, Color newColor)
 {
     CurrentColor = Input.GetCurrentColor();
     if (CurrentColor == null)
     {
         Clear();
     }
     else
     {
         if (!FlowIfCan())
         {
             return;
         }
         base.Flow(this, CurrentColor);
     }
     FlowResult();
 }
Пример #2
0
 public override void DoWork()
 {
     FlowResult(Replacement.GetCurrentColor());
 }
Пример #3
0
        public override void Work(List <IntColor> goodColors, List <Color> badColors)
        {
            int[] values = goodColors.Select(intColor => intColor.Value).ToArray();
            bool  res    = false;

            var compareType = ((CompareColor)CompareOperation.GetCurrentColor());
            var compareWith = ((IntColor)CompareWith.GetCurrentColor());

            if (compareType == null || compareWith == null)
            {
                GoBack(new ErrorSignal(new Exception("Bad arguments")));
                return;
            }
            foreach (var value in values)
            {
                switch (compareType.Value)
                {
                case (CompareType.Less):
                {
                    res = value < compareWith.Value;
                    break;
                }

                case (CompareType.LessOrEqual):
                {
                    res = value <= compareWith.Value;
                    break;
                }

                case (CompareType.Equal):
                {
                    res = value == compareWith.Value;
                    break;
                }

                case (CompareType.MoreOrEqual):
                {
                    res = value >= compareWith.Value;
                    break;
                }

                case (CompareType.More):
                {
                    res = value > compareWith.Value;
                    break;
                }

                case (CompareType.NotEqual):
                {
                    res = value != compareWith.Value;
                    break;
                }
                }
                if (!res)
                {
                    break;
                }
            }
            switch (res)
            {
            case (true):
            {
                Result = Color.Mix(goodColors.Cast <Color>());
                FlowResult();
                break;
            }

            case (false):
            {
                GoBack(new ErrorSignal(new Exception("Comparison failed")));
                break;
            }
            }
        }