Вы можете получить от Binder
класса
class MyBinder : Binder
{
public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
{
return match.First(m => m.IsGenericMethod);
}
#region not implemented
public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state) => throw new NotImplementedException();
public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture) => throw new NotImplementedException();
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers) => throw new NotImplementedException();
public override object ChangeType(object value, Type type, CultureInfo culture) => throw new NotImplementedException();
public override void ReorderArgumentArray(ref object[] args, object state) => throw new NotImplementedException();
#endregion
}
Использование:
var method = typeof(JsonConvert).GetMethod("DeserializeObject",
BindingFlags.Public | BindingFlags.Static,
new MyBinder(),
new[] {typeof(string)},
null);
В вашем случае MyBinder
получит двух кандидатов в SelectMethod
public static object DeserializeObject(string value)
public static T DeserializeObject<T>(string value)
Приведенный выше код выберет первый общий метод