Suppose I have the following .NET classes:
public class C
{
public void M()
{
....
}
}
and
public class D
{
public void N()
{
....
}
}
These 2 classes reside in different namespaces, in different assemblies. Is there a way to cause all call to C.M()
to 'redirect' automatically to D.N()
? So, the calling method things its invoking C.M
, but in reality, D.N
is what actually gets called, with any parameters that C.M
would have taken. It doesn't matter if this happens for all instantiations of the class, or just for one specific object.
MS Research has the Detours Library that can do something very similar for normal Win32 DLL exports. I'm looking for a way to do this with a .NET method.