private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist) { Type[] typeParameters = method.GetGenericArguments(); Type[] typeArguments = new Type[typeParameters.Length]; ParameterInfo[] parameters = method.GetParameters(); for (int typeIndex = 0; typeIndex < typeArguments.Length; typeIndex++) { Type typeParameter = typeParameters[typeIndex]; for (int argIndex = 0; argIndex < parameters.Length; argIndex++) { if (parameters[argIndex].ParameterType.Equals(typeParameter)) { // If a null arg is provided, pass null as the Type // BestCommonType knows how to deal with this Type argType = arglist[argIndex] != null ? arglist[argIndex].GetType() : null; typeArguments[typeIndex] = TypeHelper.BestCommonType( typeArguments[typeIndex], argType); } } } return(typeArguments); }
private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist) { Type[] typeParameters = method.GetGenericArguments(); Type[] typeArguments = new Type[typeParameters.Length]; ParameterInfo[] parameters = method.GetParameters(); for (int argIndex = 0; argIndex < parameters.Length; argIndex++) { var pi = parameters[argIndex]; var arg = arglist[argIndex]; if (pi.ParameterType.IsGenericParameter) { // If a null arg is provided, pass null as the Type // BestCommonType knows how to deal with this #if NETCF var typeArgIndex = Array.IndexOf(typeParameters, pi.ParameterType); #else var typeArgIndex = pi.ParameterType.GenericParameterPosition; #endif var argType = arg != null?arg.GetType() : null; typeArguments[typeArgIndex] = TypeHelper.BestCommonType(typeArguments[typeArgIndex], argType); } } return(typeArguments); }
private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist) { Type[] genericArguments = method.GetGenericArguments(); Type[] array = new Type[genericArguments.Length]; ParameterInfo[] parameters = method.GetParameters(); for (int i = 0; i < array.Length; i++) { Type o = genericArguments[i]; for (int j = 0; j < parameters.Length; j++) { if (parameters[j].ParameterType.Equals(o)) { array[i] = TypeHelper.BestCommonType(array[i], arglist[j].GetType()); } } } return(array); }
private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist) { Type[] typeParameters = method.GetGenericArguments(); Type[] typeArguments = new Type[typeParameters.Length]; ParameterInfo[] parameters = method.GetParameters(); for (int typeIndex = 0; typeIndex < typeArguments.Length; typeIndex++) { Type typeParameter = typeParameters[typeIndex]; for (int argIndex = 0; argIndex < parameters.Length; argIndex++) { if (parameters[argIndex].ParameterType.Equals(typeParameter)) { typeArguments[typeIndex] = TypeHelper.BestCommonType( typeArguments[typeIndex], arglist[argIndex].GetType()); } } } return(typeArguments); }