Created
May 12, 2009 17:58
-
-
Save virtualstaticvoid/110625 to your computer and use it in GitHub Desktop.
AOP via extension method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DelegateExtensions | |
{ | |
public static Func<T> Before<T>(this Func<T> func, Action before) | |
{ | |
return () => | |
{ | |
before(); | |
return func(); | |
}; | |
} | |
public static Func<T> After<T>(this Func<T> func, Action after) | |
{ | |
return () => | |
{ | |
T value = func(); | |
after(); | |
return value; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment