/// <summary> /// Adds <see cref="EfDiagramsMiddleware"/> with default <see cref="EfDiagramsOptions"/> /// to application's request pipeline. /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="app"></param> /// <returns></returns> public static IApplicationBuilder AddEfDiagrams <TDbContext>(this IApplicationBuilder app) where TDbContext : DbContext { var options = new EfDiagramsOptions { DbContextType = typeof(TDbContext) }; return(app.AddEfDiagrams(options)); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseErrorPageMiddleware" /> class /// </summary> /// <param name="next">Delegate to execute the next piece of middleware in the request pipeline.</param> /// <param name="loggerFactory"> /// The <see cref="ILoggerFactory" /> for the application. This middleware both produces logging messages and /// consumes them to detect database related exception. /// </param> /// <param name="options">The options to control what information is displayed on the error page.</param> public EfDiagramsMiddleware( RequestDelegate next, ILoggerFactory loggerFactory, IOptions <EfDiagramsOptions> options) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _options = options.Value; _logger = loggerFactory.CreateLogger <EfDiagramsMiddleware>(); }
/// <summary> /// Adds <see cref="EfDiagramsMiddleware"/> with specified <see cref="EfDiagramsOptions"/> /// to application's request pipeline. /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="app"></param> /// <returns></returns> public static IApplicationBuilder AddEfDiagrams(this IApplicationBuilder app, EfDiagramsOptions options) { var sharedOptions = new SharedOptions { FileProvider = options.FrontendAppFilesProvider, RequestPath = options.RequestPath }; app.UseDefaultFiles(new DefaultFilesOptions(sharedOptions) { DefaultFileNames = { "index.html" } }); app = app.UseStaticFiles(new StaticFileOptions(sharedOptions)); app = app.UseMiddleware <EfDiagramsMiddleware>(Options.Options.Create(options)); return(app); }