Ejemplo n.º 1
0
        /// <summary>
        /// Sets inner HTTP message handler to the current message handler.
        /// </summary>
        /// <param name="innerHandler">Instance of HttpMessageHandler.</param>
        protected void SetInnerHandler(HttpMessageHandler innerHandler)
        {
            var handlerAsDelegatingHandler = this.Handler as DelegatingHandler;

            if (handlerAsDelegatingHandler == null)
            {
                throw new HttpHandlerAssertionException(string.Format(
                                                            "When adding inner handler {0} to {1}, expected {1} to be DelegatingHandler, but in fact was not.",
                                                            innerHandler.GetName(),
                                                            this.Handler.GetName()));
            }

            handlerAsDelegatingHandler.InnerHandler = innerHandler;
        }