[Mono-list] dynamic method building

Miguel de Icaza miguel@ximian.com
13 Oct 2003 16:25:50 -0400


Hello,

> 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.

For certain kind of classes (those that derive from MarshalByRefObject),
you can actually have the runtime provide a proxy automatically for
you.  Don Box goes into the details on his "Essential .NET" book.

This functionality is also the foundation for Remoting.

> 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?

This part was unclear to me, what do you want to do?