✅ What is the best way to setup app configuration using IHostBuilder?
I want to make a good building of my host configuration and make it convenient to use. My goal is to get the as much as possible:
Currently, I'm binding it in the
Ideally, I would like to redefine
- Convenience;
- Strongly typing;
- Won't compile against typos in keys;
HostBuilderContext.Configuration["Key"]· hardcoding keys;context.Configuration.Get<Configuration>()· calling the same method everywhere;context.Configuration.Bind(configuration)· confusing where to bind it at the first time;
Currently, I'm binding it in the
IHostBuilder.ConfigureAppConfiguration:Ideally, I would like to redefine
content.Configuration so that its type matches Configuration (my custom class), in order to directly get values without hardcoding, for example: context.Configuration.Token. But I understand that this may not be possible.