Through reflection I have an object that implements a generic interface, which I don't statically know its actual type. I want call one of the interfaces methods by manipulating an Expression
. I've take a few attempts at this but I'm at a loss, any help would be greatly appreciated.
object anObject = /* Some reflection which gives IFoo<???>*/
MagicCall(anObject, x => x.MethodOnFoo("Bar"));
...
public static TReturn MagicCall<TReturn>(object obj, Expression<Func<IFoo<Object>>> expr)
{
// Some manipulation of expr and obj
return newExpr.Compile().Invoke(newObj);
}
Aucun commentaire:
Enregistrer un commentaire