コード例 #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
ファイル: Program.cs プロジェクト: greck2908/DesignPatterns
        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();
        }