@@ -3464,13 +3464,13 @@ protected virtual MethodInfo TryToCastMethodParametersToMakeItCallable(MethodInf
34643464 {
34653465 if ( paramsForInference . ParameterType . Name . StartsWith ( "Converter" ) )
34663466 {
3467- Type specificType = paramsForInference . ParameterType . GetGenericArguments ( ) . FirstOrDefault ( pType => pType . Name . Equals ( name ) ) ;
3468- MethodInfo paraMethodInfo = methodsGroupEncaps . MethodsGroup . FirstOrDefault ( mi => mi . GetParameters ( ) . Length == 1 ) ;
3469- if ( specificType != null && specificType . GenericParameterPosition == 0 )
3467+ Type specificType = Array . Find ( paramsForInference . ParameterType . GetGenericArguments ( ) , pType => pType . Name . Equals ( name ) ) ;
3468+ MethodInfo paraMethodInfo = Array . Find ( methodsGroupEncaps . MethodsGroup , mi => mi . GetParameters ( ) . Length == 1 ) ;
3469+ if ( specificType ? . GenericParameterPosition == 0 )
34703470 {
34713471 inferedTypes . Add ( paraMethodInfo . GetParameters ( ) [ 0 ] . ParameterType ) ;
34723472 }
3473- else if ( specificType != null && specificType . GenericParameterPosition == 1 )
3473+ else if ( specificType ? . GenericParameterPosition == 1 )
34743474 {
34753475 inferedTypes . Add ( paraMethodInfo . ReturnType ) ;
34763476 }
@@ -3627,7 +3627,22 @@ protected virtual MethodInfo TryToCastMethodParametersToMakeItCallable(MethodInf
36273627 }
36283628 else
36293629 {
3630- modifiedArgs [ a ] = Convert . ChangeType ( modifiedArgs [ a ] , parameterType ) ;
3630+ if ( parameterType . IsArray && modifiedArgs [ a ] is Array sourceArray )
3631+ {
3632+ modifiedArgs [ a ] = typeof ( Enumerable )
3633+ . GetMethod ( "Cast" )
3634+ . MakeGenericMethod ( parameterType . GetElementType ( ) )
3635+ . Invoke ( null , new object [ ] { modifiedArgs [ a ] } ) ;
3636+
3637+ modifiedArgs [ a ] = typeof ( Enumerable )
3638+ . GetMethod ( "ToArray" )
3639+ . MakeGenericMethod ( parameterType . GetElementType ( ) )
3640+ . Invoke ( null , new object [ ] { modifiedArgs [ a ] } ) ;
3641+ }
3642+ else
3643+ {
3644+ modifiedArgs [ a ] = Convert . ChangeType ( modifiedArgs [ a ] , parameterType ) ;
3645+ }
36313646 }
36323647 }
36333648 }
0 commit comments