I can inject the IConfiguration config into constructor and then access the app settings from json file via config["settignName"];
Example code inside service class:
public MyService(IConfiguration config)
{
_key = config["MyKey"];
}
I came across IOptions which allows to map app settings from json file to a .net object.
Example:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<MySettings>(Configuration.GetSection("MySettings"));
...
}
And then inject the IOption into the constructor.
What is the use case of IOptions versus IConfiguration (other than IOptions allows mapping to object)? I don't see IConfiguration being used in online examples so is that OK to be used or should I switch to IOption?