Hi there,
I wonder how to get a MethodInfo using System.Reflection.Type::GetMethod
when the method has a parameter which is a generic method parameter.
Consider this method:
void MyMethod<T>( T myParam) { ... }
I would like to use the GetMethod method to return the MethodInfo
corresponding to MyMethod. The signature of GetMethod is:
public sealed MethodInfo GetMethod(
string name,
BindingFlags bindingAttr,
Binder binder,
Type[] types,
ParameterModifier[] modifiers
);
The problem is: how to construct the 'types' argument since the 'myParams'
parameter is of a generic method parameter (!!0). If I had the MethodInfo, I
would make methodInfo.GetGenericArguments() to get the Type of 'myParam',
but obviously I cannot use this technique since I do not have the MethodInfo
at the moment where I want to get the type of the argument. There is a kind
of hen-or-egg problem.
There are of course workarounds, for instance using GetMethods() and
iterating.
But has anyone an idea how to solve this "cleanly"? Any suggestion would be
helpful.
Thank you.
Gael Fraiteur
Gael Fraiteur - 22 Jul 2005 12:19 GMT
Any taker?

Signature
Gael Fraiteur
http://gael.fraiteur.net