-
Notifications
You must be signed in to change notification settings - Fork 67
Add Configure<TOption, TDep1, TDep2> sugar #239
Conversation
Is there a reason you won't just add a metod taking |
We should just do both as part of this PR. May as well bring this back #152. |
/// Implementation of IConfigureOptions. | ||
/// </summary> | ||
/// <typeparam name="TOptions"></typeparam> | ||
/// <typeparam name="TDep"></typeparam> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dep1, Dep2...5
Updated PR adding Configure and PostConfigure methods taking 0 to 5 dependencies. Also added Examples: var default = services.BuildOptions<FakeOptions>()
.Configure<SomeService>((o,s) => o.Message = s.Stuff);
var named = services.BuildOptions<FakeOptions>("named")
.Configure<SomeService>((o, s) => o.Message = "named "+s.Stuff);
// Future framework methods can also expose their options builders
var xyzOptionsBuilder = services.AddXyz(o => o.Set = "Something")
.Configure(o, s => o.Other= s.Compute()) In terms of naming, we could go with |
I do think that the OptionsBuilder is the right place to put all of these extensions. I would keep the original BTW, as I mentioned in #238 (comment), I'm not that fond of calling it ** what I mean it's not building in isolation, is that these 2 calls would effectively configure the same options one after the other, and not build 2 different instances of the options, of course:
|
Yeah AddOptions might work better since it behaves like the other AddXyz()'s today where if you call it twice the options manipulations are just run in order:
|
Cool, I'll update my OptionsBuilder PR with the new names:
|
We can leave the class name alone, we already have this pattern every where (MvcBuilder/IdentityBuilder/AuthenticationBuilder), all of them are basically adding sugar methods for manipulating the IServiceCollection |
Hah, OK, I'll revert that commit then, I was about to push :) |
This should be ready to review now for real, builds on top of the new OptionsBuilder we added via @jdom 's PR:
|
For #236
Making sure the current pattern looks good before adding all of the rest boilderplate (will also add matching PostConfigure versions...
Basic idea will be to enable: (up to 5??)
These register a transient func that just uses GetRequiredService for each Dep, its up to the caller to add the deps themselves with whatever lifetime they want.
@davidfowl @ajcvickers