Files
mixtape/zero.Core/Configuration/ZeroConfigurationModule.cs
T

35 lines
1.1 KiB
C#
Raw Normal View History

2021-11-23 22:56:22 +01:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace zero.Configuration;
2022-01-06 18:10:58 +01:00
internal class ZeroConfigurationModule : ZeroModule
2021-11-23 22:56:22 +01:00
{
2021-12-12 15:41:51 +01:00
public override int Order => -1000;
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-29 00:38:55 +01:00
services.AddOptions<ZeroOptions>().Configure<IServiceProvider>((opts, svc) =>
2021-11-24 13:56:08 +01:00
{
2021-11-29 00:38:55 +01:00
opts.ServiceProvider = svc;
2021-11-24 13:56:08 +01:00
opts.Version = "0.0.1-alpha.1";
opts.ZeroPath = "/zero";
2021-11-30 14:32:10 +01:00
opts.TokenExpiration = TimeSpan.FromHours(3);
}).Bind(configuration.GetSection("Zero"));
2021-11-29 00:38:55 +01:00
services.AddTransient<IZeroOptions, ZeroOptions>(factory => factory.GetService<IOptions<ZeroOptions>>().Value);
2021-12-22 00:14:48 +01:00
services.AddScoped<IIntegrationTypeService, IntegrationTypeService>();
2021-12-22 15:41:11 +01:00
services.AddScoped<IIntegrationStore, IntegrationStore>();
2021-11-26 12:31:33 +01:00
2021-11-30 14:32:10 +01:00
services.AddOptions<FeatureOptions>().Bind(configuration.GetSection("Zero:Features"));
2021-12-23 09:07:34 +01:00
services.Configure<FlavorOptions>(opts =>
{
opts.Configure<Integration>(cfg =>
{
cfg.CanUseWithoutFlavors = false;
});
});
2021-11-23 22:56:22 +01:00
}
}