Given a simple object
public class Foo {
public void RunAction(Action<int, string, byte> action) {
Action(0, null, 0);
}
}
And given a sample pseudo-code method that reads this class to obtain the action type via reflection:
public void DoProxy(object [] calledWithParameters) {
... some code ...
}
public void DoReflection(Foo foo) {
var actionParameterInfo = foo.getType().getMethod("RunAction").GetParameters()[0];
var parameterTypes = actionParameterInfo.ParameterType.GenericTypeArguments;
// Now I have the action type and the Type[] of the necessary parameters.
}
In this case how could I create dynamically an Action that calls my DoProxy with the received parameters on call ?
Aucun commentaire:
Enregistrer un commentaire