-
Notifications
You must be signed in to change notification settings - Fork 118
[feature/10.0] Move binding logic to descriptors #8126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/10.0
Are you sure you want to change the base?
Conversation
@@ -73,6 +75,20 @@ public ICollectionRuleAction Create(IProcessInfo processInfo, BaseRecordOptions | |||
} | |||
} | |||
|
|||
internal sealed class CallbackActionDescriptor : ICollectionRuleActionDescriptor |
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.
I assume that these cannot be handled by a single generic class because the configuration source generator wouldn't be able to intercept the Bind call? Because if it could, I think all of these could be collapsed into one class.
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.
That's right, the source generator can't intercept the call if it's made on a generic parameter.
{ | ||
services.AddSingleton<TFactory>(); | ||
services.AddSingleton<CollectionRuleActionFactoryProxy<TFactory, TOptions>>(); | ||
services.AddSingleton<ICollectionRuleActionDescriptor, CollectionRuleActionDescriptor<TFactory, TOptions>>(sp => new CollectionRuleActionDescriptor<TFactory, TOptions>(actionName)); | ||
services.AddSingleton<ICollectionRuleActionDescriptor, TDescriptor>(sp => new TDescriptor()); |
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.
Do the descriptors actually need to be explicitly constructed? Couldn't service registration just do this for us e.g. services.AddSingleton<ICollectionRuleActionDescriptor, TDescriptor>()
. Same question for the other descriptor registrations. If not, you can also remove the new()
constraint on TDescriptor
.
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.
Fixed to let DI construct it for us, removed the new constraint.
- Don't construct descriptors explicitly
This is in preparation for using the configuration binding source generator, which needs the concrete type of the settings object to be available at the
Bind
callsite. We have that type available in the descriptors, so that seems like a natural place to do it. This change replaces the generic descriptor types with concrete ones that use the specific settings types.