I have an interface and a class that implements this interface, for example:
interface IMyInterface { void Func1(); void Func2(); } class Concrete : IMyInterface { public virtual void Func1() {
Now I want to create a class that will decorate each of the concrete methods of the class with some specific logic that must be executed in a non-working environment before and after the call.
class Decorator : Concrete { public override void Func1() { Pre(); base.Func1; Post(); } public virtual void Func2() { Pre(); base.Func2; Post(); } }
My question is: is there an easier way to automatically create such a class, besides using reflection on the interface, and creating a text file with the cs extension?
c # design-patterns decorator
Amittai shapira
source share