A
Andrus
Class MyClass contains a number of FindAll() methods in parent classes:
class MyClass: ActiveRecordBase<MyClass> {... }
public abstract class ActiveRecordBase<T> : ActiveRecordBase {
protected ActiveRecordBase();
public static T[] FindAll();
public static T[] FindAll(params ICriterion[] criteria);
public static T[] FindAll(DetachedCriteria criteria, params Order[] orders);
public static T[] FindAll(Order order, params ICriterion[] criteria);
public static T[] FindAll(Order[] orders, params ICriterion[] criteria);
....
}
public abstract class ActiveRecordBase : ActiveRecordHooksBase {
protected ActiveRecordBase();
protected internal static Array FindAll(Type targetType);
protected internal static Array FindAll(Type targetType, params ICriterion[]
criteria);
protected internal static Array FindAll(Type targetType, DetachedCriteria
detachedCriteria, params Order[] orders);
protected internal static Array FindAll(Type targetType, Order[] orders,
params ICriterion[] criteria);
....
I need to invoke MyClass parameterless FindAll() method using Reflection.
I tried the following code but GetMethod() returns Ambiquous match found
exception.
How to run parameterless FindAll() method ?
How to add required method signature to GetMethod() parameters or other
solution ?
Type t = Type.GetType("MyClass, MyDll");
// this line causes Ambiquous match found exception :
MethodInfo mi = t.GetMethod("FindAll",
BindingFlags.Public |
BindingFlags.FlattenHierarchy |
BindingFlags.Static);
IList<object> list = (IList<object>)mi.Invoke(null, null);
Andrus
class MyClass: ActiveRecordBase<MyClass> {... }
public abstract class ActiveRecordBase<T> : ActiveRecordBase {
protected ActiveRecordBase();
public static T[] FindAll();
public static T[] FindAll(params ICriterion[] criteria);
public static T[] FindAll(DetachedCriteria criteria, params Order[] orders);
public static T[] FindAll(Order order, params ICriterion[] criteria);
public static T[] FindAll(Order[] orders, params ICriterion[] criteria);
....
}
public abstract class ActiveRecordBase : ActiveRecordHooksBase {
protected ActiveRecordBase();
protected internal static Array FindAll(Type targetType);
protected internal static Array FindAll(Type targetType, params ICriterion[]
criteria);
protected internal static Array FindAll(Type targetType, DetachedCriteria
detachedCriteria, params Order[] orders);
protected internal static Array FindAll(Type targetType, Order[] orders,
params ICriterion[] criteria);
....
I need to invoke MyClass parameterless FindAll() method using Reflection.
I tried the following code but GetMethod() returns Ambiquous match found
exception.
How to run parameterless FindAll() method ?
How to add required method signature to GetMethod() parameters or other
solution ?
Type t = Type.GetType("MyClass, MyDll");
// this line causes Ambiquous match found exception :
MethodInfo mi = t.GetMethod("FindAll",
BindingFlags.Public |
BindingFlags.FlattenHierarchy |
BindingFlags.Static);
IList<object> list = (IList<object>)mi.Invoke(null, null);
Andrus