|
7 | 7 | using System.Linq; |
8 | 8 | using System.Linq.Expressions; |
9 | 9 | using System.Reflection; |
| 10 | +using System.Security.Claims; |
10 | 11 | using System.Threading; |
11 | 12 | using System.Threading.Tasks; |
12 | 13 | using Microsoft.AspNetCore.Http.Metadata; |
@@ -45,6 +46,7 @@ public static class RequestDelegateFactory |
45 | 46 | private static readonly MemberExpression HttpRequestExpr = Expression.Property(HttpContextExpr, nameof(HttpContext.Request)); |
46 | 47 | private static readonly MemberExpression HttpResponseExpr = Expression.Property(HttpContextExpr, nameof(HttpContext.Response)); |
47 | 48 | private static readonly MemberExpression RequestAbortedExpr = Expression.Property(HttpContextExpr, nameof(HttpContext.RequestAborted)); |
| 49 | + private static readonly MemberExpression UserExpr = Expression.Property(HttpContextExpr, nameof(HttpContext.User)); |
48 | 50 | private static readonly MemberExpression RouteValuesExpr = Expression.Property(HttpRequestExpr, nameof(HttpRequest.RouteValues)); |
49 | 51 | private static readonly MemberExpression QueryExpr = Expression.Property(HttpRequestExpr, nameof(HttpRequest.Query)); |
50 | 52 | private static readonly MemberExpression HeadersExpr = Expression.Property(HttpRequestExpr, nameof(HttpRequest.Headers)); |
@@ -221,6 +223,18 @@ private static Expression CreateArgument(ParameterInfo parameter, FactoryContext |
221 | 223 | { |
222 | 224 | return HttpContextExpr; |
223 | 225 | } |
| 226 | + else if (parameter.ParameterType == typeof(HttpRequest)) |
| 227 | + { |
| 228 | + return HttpRequestExpr; |
| 229 | + } |
| 230 | + else if (parameter.ParameterType == typeof(HttpResponse)) |
| 231 | + { |
| 232 | + return HttpResponseExpr; |
| 233 | + } |
| 234 | + else if (parameter.ParameterType == typeof(ClaimsPrincipal)) |
| 235 | + { |
| 236 | + return UserExpr; |
| 237 | + } |
224 | 238 | else if (parameter.ParameterType == typeof(CancellationToken)) |
225 | 239 | { |
226 | 240 | return RequestAbortedExpr; |
|
0 commit comments