Can I redirect .NET method calls to a new method at runtime?

后端 未结 5 935
我在风中等你
我在风中等你 2021-01-13 21:26

Suppose I have the following .NET classes:

public class C
{
    public void M()
    {
        ....
    }
}

and

public class         


        
5条回答
  •  清歌不尽
    2021-01-13 22:13

    There are mainly two possible approaches - proxying the objects or hooking the calls.

    Proxying can be done using Castle Dynamic Proxy or any similar dynamic proxy framework. Hooking the calls can either be done with aspect oriented programming with something like PostSharp or even by black magic like done by Isolator (it is designed for unit testing but it can probably be (ab)used like all other technologies)

提交回复
热议问题