Exemplo n.º 1
0
 /// <summary>
 /// Constructs a new instance of <see cref="AdminUIMiddleware"/>.
 /// </summary>
 /// <param name="options">Options for configuring <see cref="AdminUIMiddleware"/> middleware.</param>
 /// <param name="loggerFactory">Represents a type used to configure the logging system.</param>
 /// <param name="hostingEnvironment">Provides information about the web hosting environment an application is running in.</param>
 /// <param name="next">A function that can process an HTTP request.</param>
 public AdminUIMiddleware(
     AdminUIOptions options,
     ILoggerFactory loggerFactory,
     IWebHostEnvironment hostingEnvironment,
     RequestDelegate next
     )
 {
     _options = options ?? new AdminUIOptions();
     _next    = next;
     _staticFileMiddleware = CreateStaticFileMiddleware(hostingEnvironment, loggerFactory, options);
     _logger = loggerFactory.CreateLogger <AdminUIMiddleware>();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Configures a <see cref="StaticFileMiddleware"/> in order to serve the back-office application files from embedded resources.
 /// </summary>
 /// <param name="hostingEnvironment">Provides information about the web hosting environment an application is running in.</param>
 /// <param name="loggerFactory">Represents a type used to configure the logging system.</param>
 /// <param name="options">Options for configuring <see cref="AdminUIMiddleware"/> middleware.</param>
 private StaticFileMiddleware CreateStaticFileMiddleware(IWebHostEnvironment hostingEnvironment, ILoggerFactory loggerFactory, AdminUIOptions options)
 {
     _staticFileOptions = new StaticFileOptions {
         RequestPath         = string.IsNullOrEmpty(options.Path) ? string.Empty : options.Path,
         FileProvider        = new SpaFileProvider(new EmbeddedFileProvider(typeof(AdminUIMiddleware).GetTypeInfo().Assembly, EmbeddedFilesNamespace), _options),
         ContentTypeProvider = new FileExtensionContentTypeProvider()
     };
     if (options.OnPrepareResponse != null)
     {
         _staticFileOptions.OnPrepareResponse = options.OnPrepareResponse;
     }
     return(new StaticFileMiddleware(_next, hostingEnvironment, Options.Create(_staticFileOptions), loggerFactory));
 }
Exemplo n.º 3
0
 public SpaIndexFileInfo(IFileInfo template, AdminUIOptions options)
 {
     _template = template ?? throw new ArgumentNullException(nameof(template));
     _options  = options ?? throw new ArgumentNullException(nameof(options));
 }
Exemplo n.º 4
0
 public SpaFileProvider(EmbeddedFileProvider inner, AdminUIOptions options)
 {
     _inner   = inner ?? throw new ArgumentNullException(nameof(inner));
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }