internal static void SetNewArgument( string methodName, object[] arguments, object[] newArguments, ParameterInformation parameter, int index) { if (arguments.Length > index) { try { newArguments[index] = Adapter.MethodArgumentConvertTo(arguments[index], parameter.isByRef, index, parameter.parameterType, (IFormatProvider)CultureInfo.InvariantCulture); } catch (InvalidCastException ex) { throw new MethodException("MethodArgumentConversionInvalidCastArgument", (Exception)ex, "ExtendedTypeSystem", "MethodArgumentConversionException", new object[5] { (object)index, arguments[index], (object)methodName, (object)parameter.parameterType, (object)ex.Message }); } } else { newArguments[index] = parameter.defaultValue; } }
internal static object[] GetMethodArgumentsBase( string methodName, ParameterInformation[] parameters, object[] arguments, bool expandParamsOnBest) { int length1 = parameters.Length; if (length1 == 0) { return(new object[0]); } object[] newArguments = new object[length1]; for (int index = 0; index < length1 - 1; ++index) { ParameterInformation parameter = parameters[index]; Adapter.SetNewArgument(methodName, arguments, newArguments, parameter, index); } ParameterInformation parameter1 = parameters[length1 - 1]; if (!expandParamsOnBest) { Adapter.SetNewArgument(methodName, arguments, newArguments, parameter1, length1 - 1); return(newArguments); } if (arguments.Length < length1) { newArguments[length1 - 1] = (object)new ArrayList().ToArray(parameter1.parameterType.GetElementType()); return(newArguments); } int length2 = arguments.Length - length1 + 1; if (length2 == 1 && arguments[arguments.Length - 1] == null) { newArguments[length1 - 1] = (object)null; } else { object[] objArray = new object[length2]; Type elementType = parameter1.parameterType.GetElementType(); for (int index = 0; index < length2; ++index) { int parameterIndex = index + length1 - 1; try { objArray[index] = Adapter.MethodArgumentConvertTo(arguments[parameterIndex], false, parameterIndex, elementType, (IFormatProvider)CultureInfo.InvariantCulture); } catch (InvalidCastException ex) { throw new MethodException("MethodArgumentConversionInvalidCastArgument", (Exception)ex, "ExtendedTypeSystem", "MethodArgumentConversionException", new object[5] { (object)parameterIndex, arguments[parameterIndex], (object)methodName, (object)elementType, (object)ex.Message }); } } try { newArguments[length1 - 1] = Adapter.MethodArgumentConvertTo((object)objArray, parameter1.isByRef, length1 - 1, parameter1.parameterType, (IFormatProvider)CultureInfo.InvariantCulture); } catch (InvalidCastException ex) { throw new MethodException("MethodArgumentConversionParamsConversion", (Exception)ex, "ExtendedTypeSystem", "MethodArgumentConversionException", new object[5] { (object)(length1 - 1), (object)objArray, (object)methodName, (object)parameter1.parameterType, (object)ex.Message }); } } return(newArguments); }