/// <summary>
        /// Initializes a new instance of the <see cref="ResourceFileMiddleware"/> class.
        /// </summary>
        /// <param name="loggerFactory">The factory used to create loggers.</param>
        /// <param name="options">The <see cref="ResourceFileOptions"/> used to configure the middleware.</param>
        public ResourceFileMiddleware(ILoggerFactory loggerFactory, ResourceFileOptions options)
        {
            //var rm = new System.Resources.ResourceManager("Bytewizer.TinyCLR.WebServer.Properties.Resources", _options.Assembly);
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _logger = loggerFactory.CreateLogger("Bytewizer.TinyCLR.Http");

            _options             = options;
            _resources           = _options.Resources ?? new Hashtable();
            _resourceManager     = _options.ResourceManager;
            _contentTypeProvider = _options.ContentTypeProvider ?? new DefaultContentTypeProvider();
            _lastModified        = DateTime.Now;

            if (_options.ResourceManager == null)
            {
                throw new ArgumentException("Missing Resource Manager implementation.");
            }
        }
        /// <summary>
        /// Enables resource file serving for the current request path.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        /// <param name="options">The <see cref="ResourceFileOptions"/> used to configure the middleware.</param>
        public static void UseResourceFiles(this ServerOptions app, ResourceFileOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.UseMiddleware(new ResourceFileMiddleware(options));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceFileMiddleware"/> class.
 /// </summary>
 /// <param name="options">The <see cref="ResourceFileOptions"/> used to configure the middleware.</param>
 public ResourceFileMiddleware(ResourceFileOptions options)
     : this(NullLoggerFactory.Instance, options)
 {
 }
示例#4
0
        /// <summary>
        /// Enables resource file serving for the current request path.
        /// </summary>
        /// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
        /// <param name="options">The <see cref="ResourceFileOptions"/> used to configure the middleware.</param>
        public static IApplicationBuilder UseResourceFiles(this IApplicationBuilder app, ResourceFileOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(app.UseMiddleware(typeof(ResourceFileMiddleware), options));
        }