Esempio n. 1
0
        static void StructuralExampleMain()
        {
            Console.WriteLine("Structural example");

            Handler handler1 = new ConcreteHandler1();
            Handler handler2 = new ConcreteHandler2();
            Handler handler3 = new ConcreteHandler3();

            handler1.SetSuccessor(handler2);
            handler2.SetSuccessor(handler3);

            handler1.HandleRequest();

            Console.WriteLine("Real world example");

            PoSystem poSystem = new PoSystem();

            Console.WriteLine("Handle a purchase of 5000");
            poSystem.ProcessRequest(5000);
            Console.WriteLine("Handle a purchase of 15000");
            poSystem.ProcessRequest(15000);
            Console.WriteLine("Handle a purchase of 70000");
            poSystem.ProcessRequest(70000);
            Console.WriteLine("Handle a purchase of 150000");
            poSystem.ProcessRequest(150000);
        }
Esempio n. 2
0
        public void Run()
        {
            ConcreteHandler2 handler2 = new ConcreteHandler2(null);
            ConcreteHandler1 handler1 = new ConcreteHandler1(handler2);

            handler1.HandleRequest();

            Console.ReadKey();
        }