Here is the class:
class Foo
{
private void Boo()
{
// Body...
}
// Other members...
}
What I need is:
- Create a
Foo2
class at runtime which has a copy of allFoo
class members. - In
Foo2
class replaceBoo
method byBoo2
method that has its content alternated to some extent. - Create an instance of
Foo2
and invokeBoo2
.
Thank you for help.
You can do it at runtime using a .NET AOP Framework event if it is not the the main purpose of this kind of framework.
I actively work on a new one which can handle it event if your method is not virtual.
You can take a look on NConcern .NET runtime AOP Framework
The monkey patch "aspect" :
Patch :
in the second hand, if you just need to call something after the original call, you are in AOP aim and you can do it like that...
Observation Aspect :
Use case :