//[STAThread] static void Main(string[] args) { Action dec = () => Console.WriteLine("bbbbbb"); MyClass myClass = new MyClass(Console.WriteLine); var myDecClass = BeforeDecorator.GetDecoratedProxy <IMyClass>(myClass, dec); myClass.Func1(); myClass.Func2(1, "2"); myDecClass.Func1(); myDecClass.Func2(3, "4"); }
public static T GetDecoratedProxy <T>(object cls, Action decorator) { BeforeDecorator dec = new BeforeDecorator(cls, decorator); return((T)ProxyFactory.Create(dec, cls.GetType())); }