Skip to content

Instantly share code, notes, and snippets.

@virtualstaticvoid
Created May 12, 2009 17:58
Show Gist options
  • Save virtualstaticvoid/110625 to your computer and use it in GitHub Desktop.
Save virtualstaticvoid/110625 to your computer and use it in GitHub Desktop.
AOP via extension method
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