private static void ChainOfResponsibilityExample() { var handlerOne = new ConcreteHandlerOne(); var handlerTwo = new ConcreteHandlerTwo(); handlerOne.SetSuccessor(handlerTwo); handlerTwo.SetSuccessor(handlerOne); handlerOne.HandleRequest("PrintDate"); handlerOne.HandleRequest("PrintGreeting"); }
public List <int> ProcessRequests(List <int> requestTypes) { var handlers = new List <int>(); var concreteHandlerOne = new ConcreteHandlerOne(); var concreteHandlerTwo = new ConcreteHandlerTwo(); var concreteHandlerThree = new ConcreteHandlerThree(); concreteHandlerOne.SetSuccessor(concreteHandlerTwo); concreteHandlerTwo.SetSuccessor(concreteHandlerThree); foreach (var requestType in requestTypes) { handlers.Add(concreteHandlerOne.Handle(requestType)); } return(handlers); }