private static IGenericAspect CreateAspect(ITypedAspect aspect, IGenericAspect newAspect, IList mixins,
                                            IList pointcuts)
 {
     object[] aspectTargetAttributes =
         aspect.GetType().GetCustomAttributes(typeof(AspectTargetAttribute), false);
     if (aspectTargetAttributes != null)
     {
         AspectTargetAttribute aspectTargetAttribute = (AspectTargetAttribute)aspectTargetAttributes[0];
         if (aspectTargetAttribute.TargetAttribute != null)
         {
             newAspect =
                 new AttributeAspect(aspect.GetType().Name, aspectTargetAttribute.TargetAttribute, mixins,
                                     pointcuts);
         }
         else if (aspectTargetAttribute.TargetSignature != null)
         {
             newAspect =
                 new SignatureAspect(aspect.GetType().Name, aspectTargetAttribute.TargetSignature, mixins,
                                     pointcuts);
         }
         else if (aspectTargetAttribute.TargetType != null)
         {
             newAspect =
                 new SignatureAspect(aspect.GetType().Name, aspectTargetAttribute.TargetType, mixins, pointcuts);
         }
         else
         {
             throw new Exception("No target specified");
         }
     }
     return(newAspect);
 }
 private static void AddMixins(ITypedAspect aspect, IList mixins)
 {
     object[] mixinAttributes = aspect.GetType().GetCustomAttributes(typeof(MixinAttribute), false);
     if (mixinAttributes != null)
     {
         foreach (MixinAttribute mixinAttribute in mixinAttributes)
         {
             mixins.Add(mixinAttribute.MixinType);
         }
     }
 }
        private static void AddInterceptors(ITypedAspect aspect, IList pointcuts)
        {
            ArrayList methodsList = new ArrayList();

            MethodInfo[] methods =
                aspect.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                            BindingFlags.DeclaredOnly);
            foreach (MethodInfo method in methods)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof(InterceptorAttribute), false);
                if (interceptorAttributes != null && interceptorAttributes.Length > 0)
                {
                    methodsList.Add(method);
                }
            }

            methodsList.Sort(new InterceptorMethodSorter());

            foreach (MethodInfo method in methodsList)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof(InterceptorAttribute), false);
                if (interceptorAttributes != null)
                {
                    InterceptorAttribute interceptor         = (InterceptorAttribute)interceptorAttributes[0];
                    IPointcut            pointcut            = null;
                    Delegate             interceptorDelegate = CreateDelegate(aspect, method);
                    if (interceptor.TargetAttribute != null)
                    {
                        pointcut = new AttributePointcut(interceptor.TargetAttribute, interceptorDelegate);
                    }
                    else if (interceptor.TargetSignature != null)
                    {
                        pointcut = new SignaturePointcut(interceptor.TargetSignature, interceptorDelegate);
                    }
                    else
                    {
                        throw new Exception("Interceptor attribute does not contain any target info");
                    }
                    pointcuts.Add(pointcut);
                }
            }
        }
        private static void AddInterceptors(ITypedAspect aspect, IList pointcuts)
        {
            ArrayList methodsList = new ArrayList();
            MethodInfo[] methods =
                aspect.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                            BindingFlags.DeclaredOnly);
            foreach (MethodInfo method in methods)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof (InterceptorAttribute), false);
                if (interceptorAttributes != null && interceptorAttributes.Length > 0)
                {
                    methodsList.Add(method);
                }
            }

            methodsList.Sort(new InterceptorMethodSorter());

            foreach (MethodInfo method in methodsList)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof (InterceptorAttribute), false);
                if (interceptorAttributes != null)
                {
                    InterceptorAttribute interceptor = (InterceptorAttribute) interceptorAttributes[0];
                    IPointcut pointcut = null;
                    Delegate interceptorDelegate = CreateDelegate(aspect, method);
                    if (interceptor.TargetAttribute != null)
                    {
                        pointcut = new AttributePointcut(interceptor.TargetAttribute, interceptorDelegate);
                    }
                    else if (interceptor.TargetSignature != null)
                    {
                        pointcut = new SignaturePointcut(interceptor.TargetSignature, interceptorDelegate);
                    }
                    else
                    {
                        throw new Exception("Interceptor attribute does not contain any target info");
                    }
                    pointcuts.Add(pointcut);
                }
            }
        }
 private static void AddMixins(ITypedAspect aspect, IList mixins)
 {
     object[] mixinAttributes = aspect.GetType().GetCustomAttributes(typeof (MixinAttribute), false);
     if (mixinAttributes != null)
     {
         foreach (MixinAttribute mixinAttribute in mixinAttributes)
         {
             mixins.Add(mixinAttribute.MixinType);
         }
     }
 }
 private static IGenericAspect CreateAspect(ITypedAspect aspect, IGenericAspect newAspect, IList mixins,
                                            IList pointcuts)
 {
     object[] aspectTargetAttributes =
         aspect.GetType().GetCustomAttributes(typeof (AspectTargetAttribute), false);
     if (aspectTargetAttributes != null)
     {
         AspectTargetAttribute aspectTargetAttribute = (AspectTargetAttribute) aspectTargetAttributes[0];
         if (aspectTargetAttribute.TargetAttribute != null)
             newAspect =
                 new AttributeAspect(aspect.GetType().Name, aspectTargetAttribute.TargetAttribute, mixins,
                                     pointcuts);
         else if (aspectTargetAttribute.TargetSignature != null)
             newAspect =
                 new SignatureAspect(aspect.GetType().Name, aspectTargetAttribute.TargetSignature, mixins,
                                     pointcuts);
         else if (aspectTargetAttribute.TargetType != null)
             newAspect =
                 new SignatureAspect(aspect.GetType().Name, aspectTargetAttribute.TargetType, mixins, pointcuts);
         else
             throw new Exception("No target specified");
     }
     return newAspect;
 }