events - Custom attribute in .NET to execute code before and after decorated method? -


ideally i'd find way like:

[mycustomattribute()] public void mymethod() {     debug.write("b"); }  public mycustomattribute : attribute {     public void onbegin()     {         debug.write("a");        }      public void onend()     {         debug.write("c");     } } 

which write:

abc

when mymethod() gets excuted. ideas if can done? actionfilter attribute seems similar idea, applies mvc requests.

take @ postsharp - pretty already.

it post processor - takes compiled assembly, looks attributes , injects code decorated methods.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -