Which lifetime cycle has the configuration object got when it's registered the following way? Is it a singleton, transient or scoped?
{
services.Configure<SomeConfiguration>(configuration.GetSection(nameof(SomeConfiguration)));
}
This is how I get the configuration into my service class
public class SomeService: ISomeService
{
public SomeService(IOptionsMonitor<SomeConfiguration> configuration)
{
_configuration = configuration.CurrentValue;
}
}
Its is very to hard know from debugging it if its a singleton or not. Because IOptionsMonitor is able to detect changes on run time by running a watcher on appsettings.json changed
IOptions
IOptionsSnapshot:
IOptionsMonitor:
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With