예제 #1
0
        public void TestMethod()
        {
            IHandler handler1 = new InternalHandler();
            IHandler handler2 = new DiscountHandler();
            IHandler handler3 = new MailHandler();
            IHandler handler4 = new RegularHandler();

            //组合链式结构
            //internal->mail->discount->retular->null
            handler1.Successor = handler3;
            handler3.Successor = handler2;
            handler2.Successor = handler4;
            IHandler head = handler1;

            Request request = new Request(20, PurchaseType.Mail);

            head.HandleRequest(request);

            Console.ReadLine();
        }
예제 #2
0
        public void TestMethod()
        {
            IHandler handler1 = new InternalHandler();
            IHandler handler2 = new DiscountHandler();
            IHandler handler3 = new MailHandler();
            IHandler handler4 = new RegularHandler();

            //组合链式结构
            //internal->mail->discount->retular->null
            handler1.Successor = handler3;
            handler3.Successor = handler2;
            handler2.Successor = handler4;
            IHandler head = handler1;

            Request request = new Request(20, PurchaseType.Mail);
            head.HandleRequest(request);

            Console.ReadLine();
        }