Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I'm not exactly sure why, but at the moment the only way of setting up options with a factory in ASP.NET is to take an unconfigured instance of an options object, and modify it to have the correct values. There doesn't appear to be a way to just return the options object from the factory.
Describe the solution you'd like
There should be an overload in OptionsServiceCollectionExtensions of Configure that takes a Func<TOptions> so I can just return an options set instead of having to map each value manually. I have an overarching options object I first bind, then configure subsets of that options object that may need to be pulled in. Currently I need to do this:
privatereadonlyWebAppOptions_options=new();[...]_conf.Bind(_options);
services
.Configure<WebAppOptions>(_conf);
services
.Configure<TurnsProcessorOptions>(opts =>{opts.EmptyRoundsForGameDraw=_options.TurnsProcessorOptions.EmptyRoundsForGameDraw;opts.TurnTimeoutInterval=_options.TurnsProcessorOptions.TurnTimeoutInterval;});A Func<TOptions> overload would allow me to simply do:
_conf.Bind(_options);services.Configure<WebAppOptions>(_conf);services.Configure<TurnsProcessorOptions>(()=>_options.TurnsProcessorOptions);
Additional context
No response
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I'm not exactly sure why, but at the moment the only way of setting up options with a factory in ASP.NET is to take an unconfigured instance of an options object, and modify it to have the correct values. There doesn't appear to be a way to just return the options object from the factory.
Describe the solution you'd like
There should be an overload in
OptionsServiceCollectionExtensionsofConfigurethat takes aFunc<TOptions>so I can just return an options set instead of having to map each value manually. I have an overarching options object I first bind, then configure subsets of that options object that may need to be pulled in. Currently I need to do this:A
Func<TOptions>overload would allow me to simply do:Additional context
No response