コード例 #1
0
        /// <summary>
        /// Creates a new instance of the SendFileMiddleware.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
        /// <param name="encoder">The <see cref="HtmlEncoder"/> used by the default <see cref="HtmlDirectoryFormatter"/>.</param>
        /// <param name="options">The configuration for this middleware.</param>
        public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, HtmlEncoder encoder, IOptions <DirectoryBrowserOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

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

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

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

            _next         = next;
            _options      = options.Value;
            _fileProvider = _options.FileProvider ?? Helpers.ResolveFileProvider(hostingEnv);
            _formatter    = options.Value.Formatter ?? new HtmlDirectoryFormatter(encoder);
            _matchUrl     = _options.RequestPath;
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the SendFileMiddleware.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
        /// <param name="authService">The authorization service used to authorize the request.</param>
        /// <param name="pathProvider">The ILibraryPathProvider service used to determine paths to serve.</param>
        /// <param name="encoder">The <see cref="HtmlEncoder"/> used by the default <see cref="HtmlDirectoryFormatter"/>.</param>
        /// <param name="options">The configuration for this middleware.</param>
        public LibraryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IAuthorizationService authService, ILibraryPathProvider pathProvider, HtmlEncoder encoder, IOptions <LibraryBrowserOptions> options)
        {
            if (hostingEnv == null)
            {
                throw new ArgumentNullException(nameof(hostingEnv));
            }

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

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

            _next         = next ?? throw new ArgumentNullException(nameof(next));
            _options      = options.Value;
            _authService  = authService ?? throw new ArgumentNullException(nameof(authService));
            _pathProvider = pathProvider ?? throw new ArgumentNullException(nameof(pathProvider));
            _formatter    = options.Value.Formatter ?? new LibraryBrowserFormtter(encoder);
            _prefixUrl    = _options.RequestPath;
        }