Files
mixtape/zero.Core/FileStorage/ZeroFileStorageModule.cs
T

25 lines
824 B
C#
Raw Normal View History

2021-11-23 22:56:22 +01:00
using Microsoft.AspNetCore.Hosting;
2021-11-25 15:38:36 +01:00
using Microsoft.Extensions.Configuration;
2021-11-23 22:56:22 +01:00
using Microsoft.Extensions.DependencyInjection;
2021-12-03 15:49:34 +01:00
using Microsoft.Extensions.Options;
2021-11-23 22:56:22 +01:00
namespace zero.FileStorage;
2022-01-06 18:10:58 +01:00
internal class ZeroFileStorageModule : ZeroModule
2021-11-23 22:56:22 +01:00
{
2021-11-30 14:32:10 +01:00
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
2021-11-23 22:56:22 +01:00
{
2021-11-25 15:38:36 +01:00
services.AddScoped<IPaths>(factory => new Paths(factory.GetService<IWebHostEnvironment>()));
2021-11-30 14:32:10 +01:00
services.AddOptions<FileSystemOptions>().Bind(configuration.GetSection("Zero:FileSystem")).Configure(opts =>
2021-11-25 15:38:36 +01:00
{
opts.ZeroAssetsPath = "zero";
});
2022-08-05 12:16:54 +02:00
services.AddSingleton<IWebRootFileSystem, WebRootFileSystem>(svc =>
{
IWebHostEnvironment env = svc.GetRequiredService<IWebHostEnvironment>();
return new(env.WebRootPath, null);
});
2021-11-23 22:56:22 +01:00
}
}