HttpResponseHandler that can be chained into a response pipeline
Наследование: IHttpResponseHandler
Пример #1
0
        /// <summary>
        /// Add response handler to end of chain of handlers
        /// </summary>
        /// <param name="link"></param>
        /// <param name="responseHandler"></param>
        public static void AddHandler(this Link link, DelegatingResponseHandler responseHandler)
        {
            if (link.HttpResponseHandler == null)
            {
                link.HttpResponseHandler = responseHandler;
            }
            else
            {
                var currentHandler = link.HttpResponseHandler as DelegatingResponseHandler;
                if (currentHandler == null)
                {
                    throw new Exception("Cannot add handler unless existing handler is a delegating handler");
                }

                while (currentHandler != null)
                {
                    if (currentHandler.InnerResponseHandler == null)
                    {
                        currentHandler.InnerResponseHandler = responseHandler;
                        currentHandler = null;
                    }
                    else
                    {
                        currentHandler = currentHandler.InnerResponseHandler;
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Add response handler to end of chain of handlers
 /// </summary>
 /// <param name="link"></param>
 /// <param name="responseHandler"></param>
 public static void AddHandler(this Link link, DelegatingResponseHandler responseHandler)
 {
    
     if (link.HttpResponseHandler == null)
     {
         link.HttpResponseHandler = responseHandler;
     }
     else
     {
         var currentHandler = link.HttpResponseHandler as DelegatingResponseHandler;
         if (currentHandler == null) throw new Exception("Cannot add handler unless existing handler is a delegating handler");
     
         while (currentHandler != null)
         {
             if (currentHandler.InnerResponseHandler == null)
             {
                 currentHandler.InnerResponseHandler = responseHandler;
                 currentHandler = null;
             }
             else
             {
                 currentHandler = currentHandler.InnerResponseHandler;
             } 
         }
     }
 }
Пример #3
0
        public OkHandler(DelegatingResponseHandler innerHandler) : base(innerHandler)
        {

        }
Пример #4
0
 public NotFoundHandler(DelegatingResponseHandler innerHandler) : base(innerHandler)
 {
     
 }
Пример #5
0
 public ActionResponseHandler(Action<HttpResponseMessage> action, DelegatingResponseHandler innerHandler = null)
 {
     InnerResponseHandler = innerHandler;
     _action = action;
 }
Пример #6
0
 public InlineResponseHandler(Action <String, HttpResponseMessage> action, DelegatingResponseHandler innerHandler = null)
 {
     InnerResponseHandler = innerHandler;
     _action = action;
 }
Пример #7
0
 protected DelegatingResponseHandler(DelegatingResponseHandler innerResponseHandler)
 {
     InnerResponseHandler = innerResponseHandler;
 }
 protected DelegatingResponseHandler(DelegatingResponseHandler innerResponseHandler)
 {
     InnerResponseHandler = innerResponseHandler;
 }
 public InlineResponseHandler(Action<String,HttpResponseMessage> action, DelegatingResponseHandler innerHandler = null)
 {
     InnerResponseHandler = innerHandler;
     _action = action;
 }