private static DynamicMethodBody EmitAfterExecuteCall( this DynamicMethodBody body, bool condition, MethodInfo method) { if (!condition) { return(body); } var afterExecuteMi = typeof(IProxyMonitor) .GetMethod("AfterExecute"); if (method.ReturnType != typeof(void)) { body .Stloc(0) .Ldloc(0) .Box(method.ReturnType); } else { body.Ldnull(); } body .Call(afterExecuteMi); if (method.ReturnType != typeof(void)) { body.Ldloc(0); } return(body); }