public MiddlewareInjectorMiddleware(RequestDelegate next, IApplicationBuilder builder, MiddlewareInjectorOptions options) { _next = next ?? throw new ArgumentNullException(nameof(next)); _builder = builder ?? throw new ArgumentNullException(nameof(builder)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public static IApplicationBuilder UseMiddlewareInjector(this IApplicationBuilder builder, MiddlewareInjectorOptions options) { var result = builder.UseMiddleware <MiddlewareInjectorMiddleware>(builder.New(), options); //register the sources during startup options.InjectMiddleware(app => { Startup.RegisterSources(app); }); return(result); }