Ejemplo n.º 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);

            handler1.HasBreakPoint = true;
            handler1.Break        += this._Break;
            handler3.HasBreakPoint = true;
            handler3.Break        += this._Break;


            Console.ReadLine();
        }
Ejemplo n.º 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);

            handler1.HasBreakPoint = true;
            handler1.Break += this._Break;
            handler3.HasBreakPoint = true;
            handler3.Break += this._Break;

            Console.ReadLine();
        }