@@ -3464,13 +3464,13 @@ protected virtual MethodInfo TryToCastMethodParametersToMakeItCallable(MethodInf
3464
3464
{
3465
3465
if ( paramsForInference . ParameterType . Name . StartsWith ( "Converter" ) )
3466
3466
{
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 )
3470
3470
{
3471
3471
inferedTypes . Add ( paraMethodInfo . GetParameters ( ) [ 0 ] . ParameterType ) ;
3472
3472
}
3473
- else if ( specificType != null && specificType . GenericParameterPosition == 1 )
3473
+ else if ( specificType ? . GenericParameterPosition == 1 )
3474
3474
{
3475
3475
inferedTypes . Add ( paraMethodInfo . ReturnType ) ;
3476
3476
}
@@ -3627,7 +3627,22 @@ protected virtual MethodInfo TryToCastMethodParametersToMakeItCallable(MethodInf
3627
3627
}
3628
3628
else
3629
3629
{
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
+ }
3631
3646
}
3632
3647
}
3633
3648
}
0 commit comments