コード例 #1
0
 public void SetUpNewNextHandler()
 {
     TextHandler target = new TextHandler();
     BinaryHandler helpHandler = new BinaryHandler();
     target.SetNext(helpHandler);
     Assert.IsTrue(target.NextHandler == helpHandler);
 }
コード例 #2
0
        /// <summary>
        /// Sends formed request object to the handlers
        /// </summary>
        /// <param name="request">
        /// </param>
        /// <returns>
        /// Responce
        /// </returns>
        private Response HandleRequest(Request request)
        {
            // create Handlers
            var handler1 = new SessionHandler();
            var handler2 = new DirectoryHandler();
            var handler3 = new AdminHandler();
            var handler4 = new TextHandler();
            var handler5 = new BinaryHandler();
            var handler6 = new ErrorHandler();

            // set Handler sequence of execution
            handler1.SetNext(handler2);
            handler2.SetNext(handler3);
            handler3.SetNext(handler4);
            handler4.SetNext(handler5);
            handler5.SetNext(handler6);

            // handle request
            return handler1.Handle(request);
        }