-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add support for [AsParameters] attribute #133
Comments
Thanks for the request. |
Understandable. I’ll give it a go and if I’m successful I’ll raise a PR if that’s ok with you? |
Yes, it's welcome! |
With this approach - How does one specify an |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Hi! First off, congrats, this a pretty cool library and I'm currently using it (with joy!) in production. I was wondering if it would be possible to add support for something like the [AsParameters] attribute that was added to AspNetCore from .net 7.0, to augment Minimal APIs. In Asp this attribute allows for grouping all request parameters into one request class/record/struct.
AspNetCore Example:
You can see more details here
The advantage of being able to do that, is that along with the [FromServices] attribute, you will be able to have for every command delegate only two parameters. One parameter for dependency injecting all the services, and one for grouping all the arguments.
Example of how it could work
In the example above TestCommandHandler works as vehicle for injecting all necessary service dependency through its constructor. And TestCommandArgs is the vehicle for grouping all command args that become parameters, into a single record.
As you see in the example the TestCommandHandler and TestCommandArgs also implement some interfaces, name ICommandHandler and ICommandArgs. That's because another advantage of as [AsParameters] attribute is that it allows you to create one standard interface for all your command delegate handlers. Which can increase code readability, code writing speed (through IDE auto-completion) and also maintenance speed when refactoring. Here's some example interfaces for the above:
This is by no means a necessity, but it would be a pretty cool feature to add. Thanks!
The text was updated successfully, but these errors were encountered: