Example #1
0
        public AdService(IDataProvider dataProvider, IImageHelper imageHelper, IOptions <StaticFilesOptions> filesOptions, IOptions <UserOptions> userOptions, IMapper mapper)
        {
            if (filesOptions is null)
            {
                throw new ArgumentNullException(nameof(filesOptions));
            }

            _dataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider));
            _imageHelper  = imageHelper ?? throw new ArgumentNullException(nameof(imageHelper));
            _mapper       = mapper ?? throw new ArgumentNullException(nameof(mapper));
            _userOptions  = userOptions.Value;
            _options      = filesOptions.Value;
        }
        public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var configuration = app.ApplicationServices.GetService <IConfiguration>();

            var staticFilesOptions = new StaticFilesOptions();

            var staticFileConfiguration = configuration.GetSection("StaticFiles");

            staticFileConfiguration.Bind(staticFilesOptions);

            foreach (var item in staticFilesOptions.Paths)
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, item.FilePath)),
                    RequestPath  = item.RequestPath
                });
            }
        }
Example #3
0
 public ImageHelper(IOptions <StaticFilesOptions> options)
 {
     _options = options.Value;
 }