예제 #1
0
        private static void Main()
        {
            var receiver = new Receiver(false, true, false);

            var bank   = new BankPaymentHandler();
            var paypal = new PayPalPaymentHandler();
            var money  = new MoneyPaymentHandler();

            bank.Successor   = paypal;
            paypal.Successor = money;

            bank.Handle(receiver);
        }
예제 #2
0
        static void Main(string[] args)
        {
            PaymentHandler bankPaymentHandler   = new BankPaymentHandler();
            PaymentHandler moneyPaymentHnadler  = new MoneyPaymentHandler();
            PaymentHandler paypalPaymentHandler = new PayPalPaymentHandler();

            ReceiverManager receiverManager = new ReceiverManager(false, true, false);

            bankPaymentHandler.Successor   = paypalPaymentHandler;
            paypalPaymentHandler.Successor = moneyPaymentHnadler;

            moneyPaymentHnadler.Handle(receiverManager);
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title           = "Chain Of Responsibility";

            // Выставляем флаги нужных нам вариантов переводов
            Receiver receiver = new Receiver(false, true, true);

            PaymentHandler bankPaymentHandler   = new BankPaymentHandler();
            PaymentHandler moneyPaymentHandler  = new MoneyPaymentHandler();
            PaymentHandler paypalPaymentHandler = new PayPalPaymentHandler();

            bankPaymentHandler.Successor   = paypalPaymentHandler;
            paypalPaymentHandler.Successor = moneyPaymentHandler;

            bankPaymentHandler.Handle(receiver);

            receiver = new Receiver(false, true, false);
            paypalPaymentHandler.Handle(receiver);

            Console.ReadKey();
        }