/// <summary>Performs normal reflection against the given object with the given type.</summary> /// <returns>A <see cref="T:System.Type" />.</returns> /// <param name="objectType">The type of object for which to retrieve the <see cref="T:System.Reflection.IReflect" />.</param> /// <param name="instance">An instance of the type. Can be null.</param> public virtual Type GetReflectionType(Type objectType, object instance) { if (_parent != null) { return(_parent.GetReflectionType(objectType, instance)); } return(objectType); }
private static MethodInfo ChooseMethodByType(TypeDescriptionProvider provider, List<MethodInfo> methods, ICollection values) { MethodInfo info = null; Type c = null; foreach (object obj2 in values) { Type reflectionType = provider.GetReflectionType(obj2); MethodInfo info2 = null; Type type3 = null; if ((info == null) || ((c != null) && !c.IsAssignableFrom(reflectionType))) { foreach (MethodInfo info3 in methods) { ParameterInfo info4 = info3.GetParameters()[0]; if (info4 != null) { Type type4 = info4.ParameterType.IsArray ? info4.ParameterType.GetElementType() : info4.ParameterType; if ((type4 != null) && type4.IsAssignableFrom(reflectionType)) { if (info != null) { if (!type4.IsAssignableFrom(c)) { continue; } info = info3; c = type4; break; } if (info2 == null) { info2 = info3; type3 = type4; } else { bool flag = type3.IsAssignableFrom(type4); info2 = flag ? info3 : info2; type3 = flag ? type4 : type3; } } } } } if (info == null) { info = info2; c = type3; } } return info; }