Created
May 18, 2012 04:22
-
-
Save jpolvora/2723136 to your computer and use it in GitHub Desktop.
InterceptUsingActionsAndExpressionsToGetMethodNames
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
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