当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestMessage.IsInspectRequest方法代码示例

本文整理汇总了C#中System.Net.Http.HttpRequestMessage.IsInspectRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.IsInspectRequest方法的具体用法?C# HttpRequestMessage.IsInspectRequest怎么用?C# HttpRequestMessage.IsInspectRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.HttpRequestMessage的用法示例。


在下文中一共展示了HttpRequestMessage.IsInspectRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendAsync

        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (request.IsInspectRequest())
            {
                var config = GlobalConfiguration.Configuration;

                request.Properties[RequestHelper.RouteDataCache] =
                    new RouteDataInfo
                    {
                        RouteTemplate = request.GetRouteData().Route.RouteTemplate,
                        Data = request.GetRouteData().Values.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Value.ToString())).ToArray()
                    };

                request.Properties[RequestHelper.RoutesCache] = config.Routes.Select(route =>
                    new RouteInfo
                    {
                        RouteTemplate = route.RouteTemplate,
                        Defaults = route.Defaults != null ? route.Defaults.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Value.ToString())).ToArray() : null,
                        Constraints = route.Constraints != null ? route.Constraints.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Value.ToString())).ToArray() : null,
                        DataTokens = route.DataTokens != null ? route.DataTokens.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Value.ToString())).ToArray() : null,
                        Handler = route.Handler != null ? route.Handler.GetType().Name : null,
                        Picked = route.RouteTemplate == request.GetRouteData().Route.RouteTemplate
                    }).ToArray();

                var response = await base.SendAsync(request, cancellationToken);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    var newRequest = response.RequestMessage;
                    var inspectData = new InspectData(newRequest);
                    inspectData.RealHttpStatus = response.StatusCode;
                    response = newRequest.CreateResponse<InspectData>(HttpStatusCode.OK, inspectData);
                }

                response.Headers.Add(RequestHelper.InspectHeaderName, "done");

                return response;
            }

            return await base.SendAsync(request, cancellationToken);
        }
开发者ID:RomanBogomolov,项目名称:DDProject,代码行数:41,代码来源:InspectHandler.cs

示例2: SelectController

        public HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {
            if (request.IsInspectRequest())
            {
                var controllers = _innerSelector.GetControllerMapping().Values.Select(desc =>
                    new ControllerSelectionInfo
                    {
                        ControllerName = desc.ControllerName,
                        ControllerType = desc.ControllerType.AssemblyQualifiedName
                    }).ToArray();

                request.Properties[RequestHelper.ControllerCache] = controllers;
            }

            // DefaultHttpControllerSelector.SelectController
            var controllerDescriptor = _innerSelector.SelectController(request);

            // if exception is not thrown
            request.Properties[RequestHelper.SelectedController] = controllerDescriptor.ControllerName;

            return controllerDescriptor;
        }
开发者ID:shoff,项目名称:zanshin,代码行数:22,代码来源:InspectControllerSelector.cs

示例3: SelectController

        public HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {
            if (request.IsInspectRequest())
            {
                var controllers = _delegating.GetControllerMapping().Values.Select(desc =>
                    new
                    {
                        desc.ControllerName,
                        desc.ControllerType,
                    });

                request.Properties[RequestHelper.ControllerCache] = controllers;
            }

            // DefaultHttpControllerSelector.SelectController
            var controllerDescriptor = _delegating.SelectController(request);

            // if exception is not thrown
            request.Properties[RequestHelper.SelectedController] = controllerDescriptor.ControllerName;

            return controllerDescriptor;
        }
开发者ID:RickAndMSFT,项目名称:webapi.routedebugger,代码行数:22,代码来源:InspectControllerSelector.cs


注:本文中的System.Net.Http.HttpRequestMessage.IsInspectRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。