/// <summary> /// OnResult /// </summary> /// <param name="context"></param> /// <param name="returnValue"></param> public static void OnResult(AopContext context, object returnValue) { foreach (var aop in context.Aops) { if (aop != null) { aop.OnResult(context, returnValue); if (aop is IDisposable) { ((IDisposable)aop).Dispose(); } } } }
/// <summary> /// OnException /// </summary> /// <param name="context"></param> /// <param name="ex"></param> public static void OnException(AopContext context, Exception ex) { foreach (var aop in context.Aops) { if (aop != null) { aop.OnException(context, ex); if (aop is IDisposable) { ((IDisposable)aop).Dispose(); } } } }
/// <summary> /// OnExecuting /// </summary> /// <param name="proxy"></param> /// <param name="method"></param> /// <param name="args"></param> /// <param name="context"></param> public static void OnExecuting(IProxy proxy, MethodInfo method, object[] args, AopContext context) { context.Proxy = proxy; context.TargetType = proxy.GetTargetType(); context.Method = method; context.Arguments = args; var aopfuncs = proxy.GetAopFunc(); context.Aops = new List <IAop>(aopfuncs.Length); for (int i = 0; i < aopfuncs.Length; i++) { try { var aop = aopfuncs[i](); if (aop != null) { context.Aops.Add(aop); } } catch { } } context.Aops.TrimExcess(); foreach (var aop in context.Aops) { if (aop != null) { aop.OnExecuting(context); } } }