Skip to content
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

Handle commands with more than 7 parameters? #927

Closed
bounav opened this issue Jun 11, 2020 · 3 comments
Closed

Handle commands with more than 7 parameters? #927

bounav opened this issue Jun 11, 2020 · 3 comments

Comments

@bounav
Copy link

bounav commented Jun 11, 2020

CommandHandler only defines up to 7 strongly typed parameters.

What if you need more parameters for your command?

Is there a better way to handle commands with larger numbers of parameters?

Any reason more than 7 parameters are missing from the current implementation?

@bounav
Copy link
Author

bounav commented Jun 11, 2020

If you need more than 7 parameters you can declare more overloads in an extension method.

Below is an example to define a 10 parameter overload.

public static ICommandHandler Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
     Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action) =>
            HandlerDescriptor.FromDelegate(action).GetCommandHandler();

@jonsequitur
Copy link
Contributor

You can also use custom classes and options will get bound to properties or constructor parameters: #458 (comment).

@bounav
Copy link
Author

bounav commented Jun 11, 2020

Perfect, that's what I was looking for. Sorry, I forgot to check the closed issues.

@bounav bounav closed this as completed Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants