Beispiel #1
0
        public bool MethodShouldBeProxied(MethodBase method, IList aspects, Type baseType)
        {
            foreach (IAspect aspect in aspects)
            {
                IGenericAspect tmpAspect;
                if (aspect is IGenericAspect)
                {
                    tmpAspect = (IGenericAspect)aspect;
                }
                else
                {
                    tmpAspect = TypedToGenericConverter.Convert((ITypedAspect)aspect);
                }

                foreach (IPointcut pointcut in tmpAspect.Pointcuts)
                {
                    if (pointcut.IsMatch(method, baseType))
                    {
                        return(true);
                    }
                }
            }
            foreach (FixedInterceptorAttribute fixedInterceptorAttribute in method.GetCustomAttributes(typeof(FixedInterceptorAttribute), true))
            {
                return(true);
            }

            if (baseType != null)
            {
                foreach (FixedInterceptorAttribute fixedInterceptorAttribute in baseType.GetCustomAttributes(typeof(FixedInterceptorAttribute), true))
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Loops through all pointcuts in all aspects and tries to match them for a given method.
        /// </summary>
        /// <param name="method">The method to match</param>
        /// <param name="aspects">Untyped list of <c>IAspects</c></param>
        /// <returns></returns>
        public bool MethodShouldBeProxied(MethodBase method, IList aspects)
        {
            foreach (IAspect aspect in aspects)
            {
                IGenericAspect tmpAspect;
                if (aspect is IGenericAspect)
                {
                    tmpAspect = (IGenericAspect)aspect;
                }
                else
                {
                    tmpAspect = TypedToGenericConverter.Convert((ITypedAspect)aspect);
                }

                foreach (IPointcut pointcut in tmpAspect.Pointcuts)
                {
                    if (pointcut.IsMatch(method))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Matches a list of IAspects for a given type
        /// </summary>
        /// <param name="type">The type to match</param>
        /// <param name="aspects">Untyped list of <c>IAspect</c></param>
        /// <returns></returns>
        public IList MatchAspectsForType(Type type, IList aspects)
        {
            IList matches = new ArrayList();

            foreach (IAspect aspect in aspects)
            {
                IGenericAspect tmpAspect;
                if (aspect is IGenericAspect)
                {
                    tmpAspect = (IGenericAspect)aspect;
                }
                else
                {
                    tmpAspect = TypedToGenericConverter.Convert((ITypedAspect)aspect);
                }


                if (tmpAspect.IsMatch(type))
                {
                    matches.Add(aspect);
                }
            }
            return(matches);
        }