protected void Next(MyRequest myRequest)
 {
     if (_nextHandler != null)
     {
         _nextHandler.Handle(myRequest);
     }
 }
        public static void RunDemo()
        {
            var calculatorChain = new StepInitializeValue(16);

            calculatorChain
            .SetNext(new StepAddValue(-5))
            .SetNext(new StepCalcModulo(7))
            .SetNext(new StepMultiply(2));

            var request = new MyRequest()
            {
                Value = -1
            };

            calculatorChain.Handle(request);
            // ((16 + -5) % 7) * 2 = (11 % 7) * 2 = 4 * 2 = 8

            Console.WriteLine($"Calculation: ((16 + -5) % 7) * 2,  Result: {request.Value}");
        }
 public override void Handle(MyRequest myRequest)
 {
     myRequest.Value *= _multiplier;
     Next(myRequest);
 }
 public override void Handle(MyRequest myRequest)
 {
     myRequest.Value %= _divisor;
     Next(myRequest);
 }
 public override void Handle(MyRequest myRequest)
 {
     myRequest.Value += _value;
     Next(myRequest);
 }
 public abstract void Handle(MyRequest myRequest);