Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/2723136 to your computer and use it in GitHub Desktop.
Save jpolvora/2723136 to your computer and use it in GitHub Desktop.
InterceptUsingActionsAndExpressionsToGetMethodNames
static void InterceptUsingActionsAndExpressionsToGetMethodNames()
{
//pass an array of lambdas to get the names of the methods that will be intercepted
var proxyCtx = ObjectProxyFactory
.CreateUsingActions<IUnitOfWork>(new MyContext(),
pre => System.Console.WriteLine("Entering {0}", pre.CallCtx.MethodName),
pos => System.Console.WriteLine("Exiting {0}", pos.CallCtx.MethodName),
null, true,
//no magic strings
m1 => m1.SaveChanges(),
m2 => m2.ToString(),
m3 => m3.Dispose());
proxyCtx.SaveChanges();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment