68    {
   70        {
   72        }
   75        int[][] array2 = 
new int[
array.Length][];
 
   76        for (
int i = 0; 
i < 
array.Length; 
i++)
 
   77        {
   79            array2[
i] = 
new int[(parametersNoCopy.Length > args.Length) ? parametersNoCopy.Length : args.
Length];
 
   80            if (names == null)
   81            {
   82                for (int j = 0; j < args.Length; j++)
   83                {
   85                }
   86            }
   88            {
   90            }
   91        }
   93        Type[] array4 = 
new Type[args.Length];
 
   94        for (
int i = 0; 
i < args.Length; 
i++)
 
   95        {
   96            if (args[i] != null)
   97            {
   98                array4[
i] = args[
i].GetType();
 
   99            }
  100        }
  101        int num = 0;
  102        bool flag = (bindingAttr & 
BindingFlags.OptionalParamBinding) != 0;
 
  103        for (
int i = 0; 
i < 
array.Length; 
i++)
 
  104        {
  106            if (
array[i] == 
null)
 
  107            {
  108                continue;
  109            }
  111            if (parametersNoCopy2.Length == 0)
  112            {
  114                {
  115                    array2[num] = array2[
i];
 
  117                }
  118                continue;
  119            }
  120            int j;
  121            if (parametersNoCopy2.Length > args.Length)
  122            {
  123                for (j = args.Length; j < parametersNoCopy2.Length - 1 && parametersNoCopy2[j].
DefaultValue != 
DBNull.Value; j++)
 
  124                {
  125                }
  126                if (j != parametersNoCopy2.Length - 1)
  127                {
  128                    continue;
  129                }
  130                if (parametersNoCopy2[j].DefaultValue == 
DBNull.Value)
 
  131                {
  132                    if (!parametersNoCopy2[j].ParameterType.IsArray || !parametersNoCopy2[j].IsDefined(typeof(ParamArrayAttribute), inherit: true))
  133                    {
  134                        continue;
  135                    }
  137                }
  138            }
  139            else if (parametersNoCopy2.Length < args.Length)
  140            {
  141                int num2 = parametersNoCopy2.Length - 1;
  142                if (!parametersNoCopy2[num2].ParameterType.IsArray || !parametersNoCopy2[num2].IsDefined(typeof(ParamArrayAttribute), inherit: true) || array2[
i][num2] != num2)
 
  143                {
  144                    continue;
  145                }
  147            }
  148            else
  149            {
  150                int num3 = parametersNoCopy2.Length - 1;
  151                if (parametersNoCopy2[num3].ParameterType.IsArray && parametersNoCopy2[num3].IsDefined(typeof(ParamArrayAttribute), inherit: true) && array2[
i][num3] == num3 && !parametersNoCopy2[num3].ParameterType.IsAssignableFrom(array4[num3]))
 
  152                {
  154                }
  155            }
  156            int num4 = ((
type != 
null) ? (parametersNoCopy2.Length - 1) : args.Length);
 
  157            for (j = 0; j < num4; j++)
  158            {
  160                if (type2.IsByRef)
  161                {
  163                }
  164                if (type2 == array4[array2[i][j]] || (flag && args[array2[i][j]] == 
Type.Missing) || args[array2[
i][j]] == 
null || type2 == typeof(
object))
 
  165                {
  166                    continue;
  167                }
  168                if (type2.IsPrimitive)
  169                {
  170                    if (array4[array2[i][j]] == 
null || !
CanChangePrimitive(args[array2[i][j]]?.GetType(), type2))
 
  171                    {
  172                        break;
  173                    }
  174                }
  175                else if (!(array4[array2[i][j]] == 
null) && !type2.IsAssignableFrom(array4[array2[i][j]]) && (!array4[array2[
i][j]].IsCOMObject || !type2.IsInstanceOfType(args[array2[i][j]])))
 
  176                {
  177                    break;
  178                }
  179            }
  180            if (
type != 
null && j == parametersNoCopy2.Length - 1)
 
  181            {
  182                for (; j < args.Length; j++)
  183                {
  184                    if (
type.IsPrimitive)
 
  185                    {
  187                        {
  188                            break;
  189                        }
  190                    }
  191                    else if (!(array4[j] == 
null) && !
type.IsAssignableFrom(array4[j]) && (!array4[j].IsCOMObject || !
type.IsInstanceOfType(args[j])))
 
  192                    {
  193                        break;
  194                    }
  195                }
  196            }
  197            if (j == args.Length)
  198            {
  199                array2[num] = array2[
i];
 
  202            }
  203        }
  204        switch (num)
  205        {
  206        case 0:
  207            throw new MissingMethodException(SR.MissingMember);
  208        case 1:
  209        {
  210            if (names != null)
  211            {
  212                state = 
new BinderState((
int[])array2[0].
Clone(), args.Length, array3[0] != 
null);
 
  214            }
  216            if (parametersNoCopy4.Length == args.Length)
  217            {
  218                if (array3[0] != null)
  219                {
  220                    object[] array8 = new object[parametersNoCopy4.Length];
  221                    int num8 = parametersNoCopy4.Length - 1;
  222                    Array.Copy(args, array8, num8);
 
  223                    array8[num8] = 
Array.CreateInstance(array3[0], 1);
 
  224                    ((
Array)array8[num8]).SetValue(args[num8], 0);
 
  225                    args = array8;
  226                }
  227            }
  228            else if (parametersNoCopy4.Length > args.Length)
  229            {
  230                object[] array9 = new object[parametersNoCopy4.Length];
  232                for (i = 0; 
i < args.Length; 
i++)
 
  233                {
  235                }
  236                for (; 
i < parametersNoCopy4.Length - 1; 
i++)
 
  237                {
  239                }
  240                if (array3[0] != null)
  241                {
  242                    array9[
i] = 
Array.CreateInstance(array3[0], 0);
 
  243                }
  244                else
  245                {
  247                }
  248                args = array9;
  249            }
  251            {
  252                object[] array10 = new object[parametersNoCopy4.Length];
  253                int num9 = parametersNoCopy4.Length - 1;
  254                Array.Copy(args, array10, num9);
 
  255                array10[num9] = 
Array.CreateInstance(array3[0], args.Length - num9);
 
  256                Array.Copy(args, num9, (
Array)array10[num9], 0, args.Length - num9);
 
  257                args = array10;
  258            }
  260        }
  261        default:
  262        {
  263            int num5 = 0;
  264            bool flag2 = false;
  265            for (
int i = 1; 
i < num; 
i++)
 
  266            {
  268                {
  269                case 0:
  270                    flag2 = true;
  271                    break;
  272                case 2:
  274                    flag2 = false;
  275                    break;
  276                }
  277            }
  278            if (flag2)
  279            {
  281            }
  282            if (names != null)
  283            {
  284                state = 
new BinderState((
int[])array2[num5].
Clone(), args.Length, array3[num5] != 
null);
 
  286            }
  288            if (parametersNoCopy3.Length == args.Length)
  289            {
  290                if (array3[num5] != null)
  291                {
  292                    object[] array5 = new object[parametersNoCopy3.Length];
  293                    int num6 = parametersNoCopy3.Length - 1;
  294                    Array.Copy(args, array5, num6);
 
  295                    array5[num6] = 
Array.CreateInstance(array3[num5], 1);
 
  296                    ((
Array)array5[num6]).SetValue(args[num6], 0);
 
  297                    args = array5;
  298                }
  299            }
  300            else if (parametersNoCopy3.Length > args.Length)
  301            {
  302                object[] array6 = new object[parametersNoCopy3.Length];
  304                for (i = 0; 
i < args.Length; 
i++)
 
  305                {
  307                }
  308                for (; 
i < parametersNoCopy3.Length - 1; 
i++)
 
  309                {
  311                }
  312                if (array3[num5] != null)
  313                {
  314                    array6[
i] = 
Array.CreateInstance(array3[num5], 0);
 
  315                }
  316                else
  317                {
  319                }
  320                args = array6;
  321            }
  323            {
  324                object[] array7 = new object[parametersNoCopy3.Length];
  325                int num7 = parametersNoCopy3.Length - 1;
  326                Array.Copy(args, array7, num7);
 
  327                array7[num7] = 
Array.CreateInstance(array3[num5], args.Length - num7);
 
  328                Array.Copy(args, num7, (
Array)array7[num7], 0, args.Length - num7);
 
  329                args = array7;
  330            }
  332        }
  333        }
  334    }
static int FindMostSpecificMethod(MethodBase m1, int[] paramOrder1, Type paramArrayType1, MethodBase m2, int[] paramOrder2, Type paramArrayType2, Type[] types, object[] args)
 
static bool CanChangePrimitive(Type source, Type target)
 
static void ReorderParams(int[] paramOrder, object[] vars)
 
static bool CreateParamOrder(int[] paramOrder, ParameterInfo[] pars, string[] names)
 
virtual Type ParameterType
 
virtual ? object DefaultValue