static void Main(string[] args) { Handler handlerChain = new ConcreteHandler1(new ConcreteHandler2(null)); Request request1 = new ConcreteRequest1(); handlerChain.HandleRequest(request1); Request request2 = new ConcreteRequest2(); handlerChain.HandleRequest(request2); Console.ReadKey(); }
static void Main(string[] args) { ConcreteHandler1 mainHandler = new ConcreteHandler1(); mainHandler.Successor = new ConcreteHandler2(); mainHandler.Successor.Successor = new ConcreteHandler3(); int[] requests = { 0, 5, 9, 11, 18, 25, 29, 34}; foreach (var item in requests) { mainHandler.HandleRequest(item); } Console.ReadLine(); }
static void Main(string[] args) { // Setup Chain of Responsibility Handler h1 = new ConcreteHandler1(); Handler h2 = new ConcreteHandler2(); Handler h3 = new ConcreteHandler3(); h1.SetSuccessor(h2); h2.SetSuccessor(h3); // Generate and process request int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 }; foreach (int request in requests) { h1.HandleRequest(request); } Console.ReadKey(); }
static void Main(string[] args) { // Setup Chain of Responsibility AbstractHandler h1 = new ConcreteHandler1(); AbstractHandler h2 = new ConcreteHandler2(); AbstractHandler h3 = new ConcreteHandler3(); h1.SetSuccessor(h2); h2.SetSuccessor(h3); // Generate and process request int[] requests = { 20, 5, 0, -5, 220, 18, 7 }; foreach (int request in requests) { h1.HandleRequest(request); } // Wait for user Console.ReadKey(); }
/// <summary> /// Entry point into console application. /// </summary> static void Main() { // Setup Chain of Responsibility Handler h1 = new ConcreteHandler1(); Handler h2 = new ConcreteHandler2(); Handler h3 = new ConcreteHandler3(); h1.SetSuccessor(h2); h2.SetSuccessor(h3); // Generate and process request int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 }; foreach (int request in requests) { h1.HandleRequest(request); } // Wait for user Console.ReadKey(); }