Beispiel #1
0
        /// <summary>
        /// OnExecuting
        /// </summary>
        /// <param name="filterInfo"></param>
        /// <param name="context"></param>
        public static void OnExecuting(AopInfoModel filterInfo, AopContext context)
        {
            if (filterInfo.GlobalList == null)
            {
                List <Type> tlist = GetOfGlobal(filterInfo.ClassId);
                filterInfo.GlobalList = new List <IAop>(tlist.Count);
                foreach (var t in tlist)
                {
                    filterInfo.GlobalList.Add(Activator.CreateInstance(t) as IAop);
                }
            }
            foreach (var f in filterInfo.GlobalList)
            {
                f.OnExecuting(context);
            }

            if (filterInfo.TypeList == null)
            {
                var talist = GetOfType(filterInfo.ClassId, context.TagetType);
                filterInfo.TypeList = new List <IAop>(talist.Count);
                foreach (var t in talist)
                {
                    filterInfo.TypeList.Add(Activator.CreateInstance(t) as IAop);
                }
            }
            foreach (var f in filterInfo.TypeList)
            {
                f.OnExecuting(context);
            }

            if (filterInfo.TypeAttributes == null)
            {
                var arr = context.TagetType.GetCustomAttributes(typeof(AopAttribute), true);
                filterInfo.TypeAttributes = new List <AopAttribute>(arr.Length);
                foreach (var o in arr)
                {
                    filterInfo.TypeAttributes.Add(o as AopAttribute);
                }
            }
            foreach (var f in filterInfo.TypeAttributes)
            {
                f.OnExecuting(context);
            }

            if (filterInfo.MethodAttributes == null)
            {
                var arr = context.Method.GetCustomAttributes(typeof(AopAttribute), true);
                filterInfo.MethodAttributes = new List <AopAttribute>(arr.Length);
                foreach (var o in arr)
                {
                    filterInfo.MethodAttributes.Add(o as AopAttribute);
                }
            }
            foreach (var f in filterInfo.MethodAttributes)
            {
                f.OnExecuting(context);
            }
        }
Beispiel #2
0
        /// <summary>
        /// OnException
        /// </summary>
        /// <param name="filterInfo"></param>
        /// <param name="context"></param>
        /// <param name="ex"></param>
        public static void OnException(AopInfoModel filterInfo, AopContext context, Exception ex)
        {
            foreach (var f in filterInfo.GlobalList)
            {
                f.OnException(context, ex);
            }

            foreach (var f in filterInfo.TypeList)
            {
                f.OnException(context, ex);
            }

            foreach (var f in filterInfo.TypeAttributes)
            {
                f.OnException(context, ex);
            }

            foreach (var f in filterInfo.MethodAttributes)
            {
                f.OnException(context, ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// OnResult
        /// </summary>
        /// <param name="filterInfo"></param>
        /// <param name="context"></param>
        /// <param name="returnValue"></param>
        public static void OnResult(AopInfoModel filterInfo, AopContext context, object returnValue)
        {
            foreach (var f in filterInfo.GlobalList)
            {
                f.OnResult(context, returnValue);
            }

            foreach (var f in filterInfo.TypeList)
            {
                f.OnResult(context, returnValue);
            }

            foreach (var f in filterInfo.TypeAttributes)
            {
                f.OnResult(context, returnValue);
            }

            foreach (var f in filterInfo.MethodAttributes)
            {
                f.OnResult(context, returnValue);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 方法异常
 /// </summary>
 /// <param name="context">Aop上下文</param>
 /// <param name="ex">异常信息</param>
 public virtual void OnException(AopContext context, Exception ex)
 {
 }
Beispiel #5
0
 /// <summary>
 /// 方法执行后
 /// </summary>
 /// <param name="context">Aop上下文</param>
 /// <param name="returnValue">返回对象</param>
 public virtual void OnResult(AopContext context, object returnValue)
 {
 }
Beispiel #6
0
 /// <summary>
 /// 方法执行前
 /// </summary>
 /// <param name="context">Aop上下文</param>
 public virtual void OnExecuting(AopContext context)
 {
 }