コード例 #1
0
ファイル: DemoController.cs プロジェクト: yuzuruqyhe/WebAPI
        private IEnumerable <string> GetChains(DelegatingHandler handler)
        {
            yield return(handler.GetType().FullName);

            var innerHander = handler.InnerHandler as DelegatingHandler;

            if (innerHander != null)
            {
                yield return(innerHander.GetType().FullName);
            }
        }
コード例 #2
0
 void PrintMessageHandlerChain(DelegatingHandler handler)
 {
     System.Web.HttpContext.Current.Response.Write(handler.GetType().Name);
     while (null != handler.InnerHandler)
     {
         _bu.Append(" => " + handler.InnerHandler.GetType().Name);
         handler = handler.InnerHandler as DelegatingHandler;
         if (null == handler)
         {
             break;
         }
     }
     _bu.Append("<br/>");
 }
コード例 #3
0
        private IEnumerable <string> GetHandleChain(DelegatingHandler handler)
        {
            yield return(handler.GetType().Name);

            while (handler.InnerHandler != null)
            {
                yield return(handler.InnerHandler.GetType().Name);

                handler = handler.InnerHandler as DelegatingHandler;
                if (handler == null)
                {
                    break;
                }
            }
        }
コード例 #4
0
 protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     return(_traceWriter.TraceBeginEndAsync <HttpResponseMessage>(
                request,
                TraceCategories.MessageHandlersCategory,
                TraceLevel.Info,
                _innerHandler.GetType().Name,
                SendAsyncMethodName,
                beginTrace: null,
                execute: () => base.SendAsync(request, cancellationToken),
                endTrace: (tr, response) =>
     {
         if (response != null)
         {
             tr.Status = response.StatusCode;
         }
     },
                errorTrace: null));
 }