jeudi 25 février 2016

How can I change the behavior of a static method at runtime?

Is there a way to modify the behavior of a static method at runtime?

for example:

Say I have this class

public class Utility {

    public static void DoSomething(string data){
        //...
    }
}

Is there a way to do something like this:

typeof(Utility).SetMethod("DoSomething", (data) => { /*Do something else...*/ });

Such that if you call Utility.DoSomething it executes the new code?





Aucun commentaire:

Enregistrer un commentaire