[Mono-list] dynamic method building

Christopher Taylor ct@CLEMSON.EDU
Mon, 13 Oct 2003 10:35:38 -0400

I'm currently trying to write a class for monitoring object behavior 
and currently i've decided it'd be easier to try implementing this 
class using reflection.emit

right now i'd like to be able to take class A and create a new class B 
that inherits from A.

class B then overrides all of A's methods using Reflection.Emit and 
provides new code for monitoring calls on A and then 
forwarding/mimicking the behavior of A.

so i'd be like this:

class A
	public A() {}

	public void printMe() { Console.WriteLine("Blah"); }

class B would be made at runtime and it'd inherit from A then it would 
override printMe
with code to perform monitoring and then it'd make a call to A's 
version of printMe().

My question is... I know how to make dynamic types but how do i define 
dynamic functions i noticed that MethodBuilder requires IL codes 
inorder to perform it's magic.

Is there a way i can define a method's body with a string and then have 
some part of the reflection/reflection.emit namespace generate ILcodes 
for that string?

much thanks,