.Net Reflection - Calling unexisting methods

Posted by Joaozinho das Couves on Stack Overflow See other posts from Stack Overflow or by Joaozinho das Couves
Published on 2010-04-20T16:13:33Z Indexed on 2010/04/20 16:23 UTC
Read the original article Hit count: 306

Filed under:
|
|

Lets say i call method M1 on class A using reflection. The method does not exist.

Is there any way to put a handler on class A that says, "someone is trying to execute method M1"?

Or

Is it possible to add a method dinamically to a class? I want to add a method M1...Mn that always does MyStaticClass.DoAction("M1...Mn");

Something like:

string methodName = "M1".

A.AddMethod(methodname,x => MyStaticClass.DoAction(x));

Thanks

© Stack Overflow or respective owner

Related posts about reflection

Related posts about .NET