static void Main(string[] args) { var o = new Foo(); o.A(); o.B(); Console.ReadKey(); }
static void Main(string[] args) { Interceptor[] interceptor = new[] { new Interceptor(typeof(Samples).GetMethod("A"), typeof(Samples).GetMethod("B")), new Interceptor(typeof(Foo).GetMethod("A"), typeof(Foo).GetMethod("B")), new Interceptor(typeof(Foo).GetMethod("G"), typeof(Samples).GetMethod("G")), }; A(1, 2); Foo foo = new Foo(); foo.A(); foo.G(3); interceptor[2].Invoke(() => foo.G(3)); Console.ReadKey(false); }