25 lines
824 B
C#
25 lines
824 B
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace zero.FileStorage;
|
|
|
|
internal class ZeroFileStorageModule : ZeroModule
|
|
{
|
|
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.AddScoped<IPaths>(factory => new Paths(factory.GetService<IWebHostEnvironment>()));
|
|
|
|
services.AddOptions<FileSystemOptions>().Bind(configuration.GetSection("Zero:FileSystem")).Configure(opts =>
|
|
{
|
|
opts.ZeroAssetsPath = "zero";
|
|
});
|
|
|
|
services.AddSingleton<IWebRootFileSystem, WebRootFileSystem>(svc =>
|
|
{
|
|
IWebHostEnvironment env = svc.GetRequiredService<IWebHostEnvironment>();
|
|
return new(env.WebRootPath, null);
|
|
});
|
|
}
|
|
} |