Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 6bc8384

Browse files
committed
Small style cleanup
1 parent ca8136b commit 6bc8384

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/Microsoft.AspNet.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public static IApplicationBuilder UseMiddleware(this IApplicationBuilder app, Ty
9595

9696
private static Func<T, HttpContext, IServiceProvider, Task> Compile<T>(MethodInfo methodinfo, ParameterInfo[] parameters)
9797
{
98-
9998
// If we call something like
10099
//
101100
// public class Middleware
@@ -122,17 +121,6 @@ private static Func<T, HttpContext, IServiceProvider, Task> Compile<T>(MethodInf
122121
// return ((Middleware)instance).Invoke(httpContext, (ILoggerFactory)UseMiddlewareExtensions.GetService(provider, typeof(ILoggerFactory));
123122
// }
124123

125-
// context =>
126-
// {
127-
// var serviceProvider = context.RequestServices ?? applicationServices;
128-
// if (serviceProvider == null)
129-
// {
130-
// throw new InvalidOperationException(Resources.FormatException_UseMiddlewareIServiceProviderNotAvailable(nameof(IServiceProvider)));
131-
// }
132-
//
133-
// return Invoke(httpContext, serviceProvider);
134-
// }
135-
136124
var middleware = typeof(T);
137125

138126
var httpContextArg = Expression.Parameter(typeof(HttpContext), "httpContext");
@@ -149,12 +137,15 @@ private static Func<T, HttpContext, IServiceProvider, Task> Compile<T>(MethodInf
149137
throw new NotSupportedException(Resources.FormatException_InvokeDoesNotSupportRefOrOutParams(InvokeMethodName));
150138
}
151139

152-
var parameterTypeExpression = new Expression[] {
153-
providerArg,
154-
Expression.Constant(parameterType, typeof(Type)),
155-
Expression.Constant(methodinfo.DeclaringType, typeof(Type))
156-
};
157-
methodArguments[i] = Expression.Convert(Expression.Call(GetServiceInfo, parameterTypeExpression), parameterType);
140+
var parameterTypeExpression = new Expression[]
141+
{
142+
providerArg,
143+
Expression.Constant(parameterType, typeof(Type)),
144+
Expression.Constant(methodinfo.DeclaringType, typeof(Type))
145+
};
146+
147+
var getServiceCall = Expression.Call(GetServiceInfo, parameterTypeExpression);
148+
methodArguments[i] = Expression.Convert(getServiceCall, parameterType);
158149
}
159150

160151
Expression middlewareInstanceArg = instanceArg;

0 commit comments

Comments
 (0)