Skip to content

Commit

Permalink
Address final review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Mar 29, 2021
1 parent 9e757bf commit 65a873f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Http/Http.Extensions/src/RequestDelegateFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// Builds <see cref="RequestDelegate"/> implementations from <see cref="Delegate"/> request handlers.
/// Creates <see cref="RequestDelegate"/> implementations from <see cref="Delegate"/> request handlers.
/// </summary>
public static class RequestDelegateFactory
{
Expand Down Expand Up @@ -47,10 +47,10 @@ public static class RequestDelegateFactory
private static readonly MemberExpression RequestAbortedExpr = Expression.Property(HttpContextParameter, nameof(HttpContext.RequestAborted));

/// <summary>
/// Builds a <see cref="RequestDelegate"/> implementation for <paramref name="action"/>.
/// Creates a <see cref="RequestDelegate"/> implementation for <paramref name="action"/>.
/// </summary>
/// <param name="action">A request handler with any number of custom parameters that often produces a response with its return value.</param>
/// <returns>The <see cref="RequestDelegate"/></returns>
/// <returns>The <see cref="RequestDelegate"/>.</returns>
public static RequestDelegate Create(Delegate action)
{
if (action is null)
Expand All @@ -60,11 +60,11 @@ public static RequestDelegate Create(Delegate action)

var targetExpression = action.Target switch
{
{ } => Expression.Convert(TargetArg, action.Target.GetType()),
object => Expression.Convert(TargetArg, action.Target.GetType()),
null => null,
};

var untargetedRequestDelegate = BuildRequestDelegate(action.Method, targetExpression);
var untargetedRequestDelegate = CreateRequestDelegate(action.Method, targetExpression);

return httpContext =>
{
Expand All @@ -73,18 +73,18 @@ public static RequestDelegate Create(Delegate action)
}

/// <summary>
/// Builds a <see cref="RequestDelegate"/> implementation for <paramref name="methodInfo"/>.
/// Creates a <see cref="RequestDelegate"/> implementation for <paramref name="methodInfo"/>.
/// </summary>
/// <param name="methodInfo">A static request handler with any number of custom parameters that often produces a response with its return value.</param>
/// <returns>The <see cref="RequestDelegate"/></returns>
/// <returns>The <see cref="RequestDelegate"/>.</returns>
public static RequestDelegate Create(MethodInfo methodInfo)
{
if (methodInfo is null)
{
throw new ArgumentNullException(nameof(methodInfo));
}

var untargetedRequestDelegate = BuildRequestDelegate(methodInfo, targetExpression: null);
var untargetedRequestDelegate = CreateRequestDelegate(methodInfo, targetExpression: null);

return httpContext =>
{
Expand All @@ -93,11 +93,11 @@ public static RequestDelegate Create(MethodInfo methodInfo)
}

/// <summary>
/// Builds a <see cref="RequestDelegate"/> implementation for <paramref name="methodInfo"/>.
/// Creates a <see cref="RequestDelegate"/> implementation for <paramref name="methodInfo"/>.
/// </summary>
/// <param name="methodInfo">A request handler with any number of custom parameters that often produces a response with its return value.</param>
/// <param name="targetFactory">Creates the <see langword="this"/> for the non-static method.</param>
/// <returns>The <see cref="RequestDelegate"/></returns>
/// <returns>The <see cref="RequestDelegate"/>.</returns>
public static RequestDelegate Create(MethodInfo methodInfo, Func<HttpContext, object> targetFactory)
{
if (methodInfo is null)
Expand All @@ -116,15 +116,15 @@ public static RequestDelegate Create(MethodInfo methodInfo, Func<HttpContext, ob
}

var targetExpression = Expression.Convert(TargetArg, methodInfo.DeclaringType);
var untargetedRequestDelegate = BuildRequestDelegate(methodInfo, targetExpression);
var untargetedRequestDelegate = CreateRequestDelegate(methodInfo, targetExpression);

return httpContext =>
{
return untargetedRequestDelegate(targetFactory(httpContext), httpContext);
};
}

private static Func<object?, HttpContext, Task> BuildRequestDelegate(MethodInfo methodInfo, Expression? targetExpression)
private static Func<object?, HttpContext, Task> CreateRequestDelegate(MethodInfo methodInfo, Expression? targetExpression)
{
// Non void return type

Expand Down

0 comments on commit 65a873f

Please sign in to comment.