private void CheckAspects(AspectDefinitionCollection aspects)
 {
     foreach (AspectDefinition aspect in aspects)
     {
         AssertUnique(_aspectNames, aspect, aspect.Name, "The name given to an aspect must be unique");
         AssertNotNull(aspect, aspect.TargetType, "Aspect must have a target type");
         CheckIncludes(aspect.Mixins);
         CheckPointcuts(aspect.PointCuts);
     }
 }
Beispiel #2
0
        public AspectDefinition[] Match(Type targetType, AspectDefinitionCollection aspects)
        {
            // TODO: think about caches here...

            ArrayList list = new ArrayList();

            foreach (AspectDefinition aspect in aspects)
            {
                IClassMatcher matcher = ObtainClassMatcher(aspect);

                if (matcher.Match(targetType, aspect))
                {
                    list.Add(aspect);
                }
            }

            return((AspectDefinition[])list.ToArray(typeof(AspectDefinition)));
        }
        public AspectAttributesMemberMatcher(Type aspectDeclaringType, IAspectMemebrsCollection aspectMembersCollection)
        {
            Values = aspectMembersCollection.Select(aspectMembers => {
                var aspects = aspectMembers.Members.SelectMany(member => {
                    var onMethodBoundaryAspects   = member.GetCustomAttributes <OnMethodBoundaryAspectAttribute>();
                    var methodInterceptionAspects = member.GetCustomAttributes <MethodInterceptionAspectAttribute>();

                    var onMethodBoundaryAspectDefinitions = onMethodBoundaryAspects.Select(aspect => {
                        return(new OnMethodBoundaryAspectDefinition(aspect, aspectDeclaringType, aspectMembers.Target));
                    });

                    var methodInterceptionAspectDefinitions = methodInterceptionAspects.Select(aspect => {
                        return(new MethodInterceptionAspectDefinition(aspect, aspectDeclaringType, aspectMembers.Target));
                    });

                    return(methodInterceptionAspectDefinitions.Cast <IAspectDefinition>()
                           .Concat(onMethodBoundaryAspectDefinitions));
                });

                var aspectsCollection = new AspectDefinitionCollection(aspects) as IAspectDefinitionCollection;

                return(Tuple.Create(aspectMembers.Target, aspectsCollection));
            });
        }