I'd like to be able to get a collection of all IOptions<T> registered in autofac so that I can save them to a custom JSON file. Something like:
class OptionsManager(IEnumerable IOptions)
I don't know if this is even possible because there is not AFAIK a non-generic IOptions interface, and currently I don't actually register the options per se, I build a service collection that adds them, and that gets populates my container via an extension:
var builder = new ContainerBuilder();
var serviceCollection = new ServiceCollection().AddOptions();
builder.Populate(serviceCollection);
Which doesn't expose any way for me to reigster the these options under a single interface anyways.
I could register all my classes under my own generic interface, IOptions or a common base class or something. But this doesn't prevent me from using a class outside of this interface as an IOptions<T> and further, I don't think the classes I register would be the same as the ones provided by the IOptions<T> registration, so it wouldn't even work.
I could just abandon IOptions<T> all together, but that means I have to expose my own Options interface for others to implement, which I can do, but I would rather not.
You could try following sample register to
IOptions<object>:Console app, Package
Microsoft.Extensions.ConfigurationMicrosoft.Extensions.Configuration.JsonMicrosoft.Extensions.Configuration.BinderMicrosoft.Extensions.Options``Appsettings.json
option type
Test result
