Example #1
0
    // Entry point into console application.
    static void Main()
    {
        // Setup Chain of Responsibility (top-down)
        Handler h4 = new ConcreteHandler4();
        Handler h3 = new ConcreteHandler3(h4);
        Handler h2 = new ConcreteHandler2();
        Handler h1 = new ConcreteHandler1();

        h1.SetSuccessor(h2);
        h2.SetSuccessor(h3);

        // Generate requests
        int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20, 3, 35, 50, 39, 42, 32 };

        // Process requests
        foreach (int request in requests)
        {
            h1.HandleRequest(request);
        }

        // Wait for user
        Console.ReadKey();
    }
    // Entry point into console application.
    static void Main()
    {
        // Setup Chain of Responsibility (top-down)
        Handler h4 = new ConcreteHandler4();
        Handler h3 = new ConcreteHandler3(h4);
        Handler h2 = new ConcreteHandler2();
        Handler h1 = new ConcreteHandler1();

        h1.SetSuccessor(h2);
        h2.SetSuccessor(h3);

        // Generate requests
        int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20, 3, 35, 50, 39, 42, 32 };

        // Process requests
        foreach (int request in requests)
            h1.HandleRequest(request);

        // Wait for user
        Console.ReadKey();
    }