public static object AroundConstructor(MethodJoinPoint jp) { if (jp.NbParameters > 0) { jp[0] = "intercepted " + jp[0]; } return jp.Proceed(); }
public static object CallMethod(MethodJoinPoint jp) { object result = null; PrintJoinPoint(jp); MethodInfo mi = target.GetType().GetMethod(jp.TargetOperationName); result = mi.Invoke(target, jp.Arguments); return result; }
public void LogTest() { // prepare test objects (need to create an instance of MethodJoinPoint var duUtils = new DngUtils(); MethodBase mbMethod = duUtils.GetType().GetMethod("injectHooks"); var oParams = new object[] {"Param1", "2nd Param", " Parameter #3"}; var ojpOperationJoinPoint = new MethodJoinPoint(duUtils, oParams, mbMethod); Assert.IsNotNull(ojpOperationJoinPoint, "Could not create OperationoinPoint object"); Assert.IsTrue(ojpOperationJoinPoint.RealTarget == duUtils, "Prob with RealTarget"); Assert.IsTrue(ojpOperationJoinPoint.NbParameters == oParams.Length, "Prob with NbParameters"); Assert.IsTrue(ojpOperationJoinPoint.TargetOperation == mbMethod, "Prob with TargetOperation"); var createdLogFile = DngAspect.Log(ojpOperationJoinPoint, "return Data"); Assert.That(File.Exists(createdLogFile),"probs with createdLogFile"); }
public static object ValueProperty(MethodJoinPoint jp) { Console.WriteLine("*** target : {0}", jp.RealTarget); IArgDef adef = jp.RealTarget as IArgDef; if (adef != null) { Console.WriteLine("expression:{0}, argtype:{1}", adef.Expression, adef.ArgType); } object result = jp.Proceed(); return result; }
public static object ValueProperty(MethodJoinPoint jp) { object result = null; IArgDef adef = jp.RealTarget as IArgDef; string expression = adef.Expression; if (expression != null && expression.IndexOf("#") > -1) { Hashtable table = new Hashtable(); table["container"] = adef.Container; table["appSettings"] = ConfigurationManager.AppSettings; result = ExpressionEvaluator.GetValue(null, expression, table); } else { result = jp.Proceed(); } return result; }
public static object AroundStaticConstructor(MethodJoinPoint jp) { object result = jp.Proceed(); B.staticVal *=2; return result; }
public static object AroundNestedClass(MethodJoinPoint jp) { return jp.Proceed(); }
public static object AroundCtor(MethodJoinPoint jp) { jp[0] = " intercepted " + jp[0]; return jp.Proceed(); }
public static object StaticInterceptorMixedTypes(MethodJoinPoint jp) { string s = (string)jp[2]; int i = (int)jp.Proceed(); return s.Length + i; }
public static object InterceptorPrimitiveTypes(MethodJoinPoint jp) { int val1 = (int)jp[0]; double val2 = (double)jp[1]; return val1 + (int)val2; }
public static object AroundExternalCall(MethodJoinPoint jp) { System.Console.Write(""); // To check whether this invocation is excluded (else -> stack overflow) return jp.Proceed(); }
public static object InterceptPorperty(MethodJoinPoint jp) { Console.WriteLine("--- before property get : {0}", jp); return jp.Proceed(); }
public static object AroundTargetMethod(MethodJoinPoint jp) { return jp.Proceed(); }