c# - Can I create a wrapper that intercept all calls to objects implementing certain interface? -
let's have interface ifoo
interface ifoo { int bar(); int bar2(); void vbar(); //etc, }
can create wrapper takes ifoo object , before/after actual call?
e.g. when this
ifoo wrappedfoo = new wrapper<ifoo>(actualfooobject).object; wrappedfoo.bar();
then wrapper.bar() method execute this
precall(); //some code can define in wrapper actualfooobject.bar(); postcall();
is there simple , clean way this?
you can use code contracts approach. take on section 2.8 interface contracts
of user manual (pdf).
Comments
Post a Comment