static void Main(string[] args)
        {
            // composite
            var ba          = new BankAccount();
            var cmdDeposit  = new BankAccountCommand(ba, BankAccountCommand.Action.Deposit, 100);
            var cmdWithdraw = new BankAccountCommand(ba, BankAccountCommand.Action.Withdraw, 1000);
            var composite   = new CompositeBankAccountCommand(new[] { cmdDeposit, cmdWithdraw });

            composite.Call();
            Console.WriteLine(ba);

            composite.Undo();
            Console.WriteLine(ba);


            // money transfer
            var from = new BankAccount();

            from.Deposit(100);
            var to = new BankAccount();

            var mtc = new MoneyTransferCommand(from, to, 1000);

            mtc.Call();

            Console.WriteLine(from);
            Console.WriteLine(to);

            mtc.Undo();

            Console.WriteLine(from);
            Console.WriteLine(to);
        }
        public override void Call()
        {
            BankAccountCommand last = null;

            foreach (var cmd in this)
            {
                if (last == null || last.Success)
                {
                    cmd.Call();
                    last = cmd;
                }
                else
                {
                    cmd.Undo();
                    break;
                }
            }
        }