Example #1
0
        public Chain AddToChain(Chain node)
        {
            if (next == null)
            {
                next = node;
            }
            else
            {
                next.AddToChain(node);
            }

            return(this);
        }
Example #2
0
        static void Main(string[] args)
        {
            var chain = new Chain();

            chain.AddToChain(new Addition())
            .AddToChain(new Subtraction())
            .AddToChain(new Multiplication());

            Numbers numbers = new Numbers(5, 10, OperationType.Mul);
            var     result  = chain.Calculate(numbers);

            Console.WriteLine(result);
        }