private Tuple <MethodInfo, object[]> CheckParameters(MethodInfo method) { ParameterInfo[] parameters = method.GetParameters(); int len = parameters.Length; object[] args2 = new object[len]; Type[] argTypes2 = new Type[len]; if (len > 0 && len < args1.Length) { bool isParams = Attribute.IsDefined(parameters[len - 1], typeof(ParamArrayAttribute)); if (isParams) { for (int i = 0; i < len - 1; i++) { args2[i] = args1[i]; argTypes2[i] = argTypes1[i]; } Type ty = parameters[len - 1].ParameterType; Array array = (Array)Activator.CreateInstance(ty, new object[] { args1.Length - len + 1 }); for (int i = 0; i < args1.Length - len + 1; i++) { array.SetValue(args1[len + i - 1], i); } args2[len - 1] = array; argTypes2[len - 1] = ty; goto L1; } } if (len != args1.Length) { return(null); } for (int i = 0; i < len; i++) { args2[i] = args1[i]; argTypes2[i] = argTypes1[i]; } L1: GenericArguments gas = new GenericArguments(); for (int i = 0; i < len; i++) { if (!HostOperation.IsCompatibleType(parameters[i].ParameterType, args2[i], argTypes2[i])) { if (args2[i] == null && argTypes2[i] == null) { return(null); } object temp = gas.CheckCompatibleType(parameters[i], args2[i], argTypes2[i]); if (temp == null) { return(null); } args2[i] = temp; } } if (method.IsGenericMethod && method.IsGenericMethodDefinition) { Type[] gaty2 = gas.ConstructGenericArguments(method.GetGenericArguments()); method = method.MakeGenericMethod(gaty2); } return(Tuple.Create(method, args2)); }