本文整理汇总了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);
}
示例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;
}
示例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;
}