public static AbstractHandler SetUpAnimalFeedChain2()
        {
            // The other part of the client code constructs the actual chain.
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            squirrel.SetNext(dog);

            return(squirrel);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Chain of Responsibility!");

            AbstractHandler squirrel = new SquirrelHandler();
            AbstractHandler dog      = new DogHandler();

            squirrel.SetNext(squirrel).SetNext(dog);

            HandleRequest(squirrel);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // The other part of the client code constructs the actual chain.
            var monkey   = new MonkeyHandler();
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(squirrel).SetNext(dog);

            Console.WriteLine("Chain: Monkey > Squirrel > Dog\n");
            Client.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Subchain: Squirrel > Dog\n");
            Client.ClientCode(squirrel);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var monkey   = new MonkeyHandler();
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(squirrel).SetNext(dog);

            //The client should be able to send a request to any handler, not just the first one in the chain.
            Console.WriteLine("Chain: Monkey > Squirrel > Dog\n");
            Client.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Subchain: Squirrel > Dog\n");
            Client.ClientCode(squirrel);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // Другая часть клиентского кода создает саму цепочку.
            var monkey   = new MonkeyHandler();
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(squirrel).SetNext(dog);

            // Клиент должен иметь возможность отправлять запрос любому
            // обработчику, а не только первому в цепочке.
            Console.WriteLine("Chain: Monkey > Squirrel > Dog\n");
            Client.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Subchain: Squirrel > Dog\n");
            Client.ClientCode(squirrel);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var monkey   = new MonkeyHandler();
            var Squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(Squirrel).SetNext(dog);

            Console.WriteLine("Chain: Monkey>Squirrel>Dog \n");

            Client.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Sub Chain: Squirrel> Dog \n");
            Client.ClientCode(Squirrel);

            Console.ReadLine();
        }