@@ -139,6 +139,34 @@ public static ICommandHandler Create<T1, T2, T3, T4, T5, T6, T7>(
139
139
Func < T1 , T2 , T3 , T4 , T5 , T6 , T7 , Task < int > > action ) =>
140
140
HandlerDescriptor . FromDelegate ( action ) . GetCommandHandler ( ) ;
141
141
142
+ public static ICommandHandler Create < T1 , T2 , T3 > (
143
+ IValueDescriptor < T1 > symbol1 ,
144
+ IValueDescriptor < T2 > symbol2 ,
145
+ IValueDescriptor < T3 > symbol3 ,
146
+ Func < T1 , T2 , T3 , Task > handle )
147
+ {
148
+ return new AnonymousCommandHandler ( async context =>
149
+ {
150
+ await handle (
151
+ context . ParseResult . ValueFor ( symbol1 ) ,
152
+ context . ParseResult . ValueFor ( symbol2 ) ,
153
+ context . ParseResult . ValueFor ( symbol3 ) ) ;
154
+ } ) ;
155
+ }
156
+
157
+ private class AnonymousCommandHandler : ICommandHandler
158
+ {
159
+ private readonly Func < InvocationContext , Task > _getResult ;
160
+
161
+ public AnonymousCommandHandler ( Func < InvocationContext , Task > getResult )
162
+ {
163
+ _getResult = getResult ;
164
+ }
165
+
166
+ public async Task < int > InvokeAsync ( InvocationContext context ) =>
167
+ await GetResultCodeAsync ( _getResult ( context ) , context ) ;
168
+ }
169
+
142
170
internal static async Task < int > GetResultCodeAsync ( object value , InvocationContext context )
143
171
{
144
172
switch ( value )
0 commit comments