I need to extend the behavior of an instance, but I do not have access to the source code for this instance. For instance:
Class AB { public void execute(); }
in my code, I would intercept every call to execute, compute some sutff, and then call the original execute, something like
SomeType m_OrgExecute; { AB a = new AB(); m_OrgExecute = GetByReflection( a.execute ); a.execute = MyExecute; } void MyExecute() { System.Console.Writeln( "In MyExecute" ); m_OrgExecute(); }
Is it possible?
Does anyone have a solution to this problem?
source share