Helper methods for configuring services with dependency injection.
- In a Web API project.
builder.Services.AddAppSettings<MyAppSettings>(builder.Configuration);
- In a console project.
var host = Host
.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
var config = services.BuildServiceProvider()
.GetRequiredService<IConfiguration>();
services.AddAppSettings<MyAppSettings>(config);
})
.Build();