public IEnumerable <Advice> GetAdvices(Aspect aspect) { ArgumentUtility.CheckNotNull("aspect", aspect); foreach (var method in aspect.Type.GetMethods()) { var adviceAttribute = method.GetCustomAttributes <AdviceAttribute> (true).SingleOrDefault(); if (adviceAttribute == null) { continue; } var execution = adviceAttribute.Execution; var attributePointcut = _pointcutBuilder.Build(method); var mappings = _contextMappingBuilder.GetMappingsAndPointcut(method); var pointcut = new AllPointcut(new[] { attributePointcut, mappings.Item2 }); var orderings = new List <IOrdering>(); var crosscutting = new Crosscutting(pointcut, orderings, method.Name); orderings.AddRange(_orderingBuilder.BuildOrderings(crosscutting, method)); yield return(new Advice(aspect, method, execution, crosscutting)); } }
private Aspect Build(Type type, IAspectInfo info, IAspectConstruction construction, IPointcut pointcut, int priority = 0) { var scope = info.Scope; var activation = info.Activation; var role = info.Role; var orderings = new List <IOrdering>(); var crosscutting = new Crosscutting(pointcut, orderings, priority, type, role); orderings.AddRange(_orderingBuilder.BuildOrderings(crosscutting, type)); var advices = new List <Advice>(); var introductions = new List <MemberIntroduction>(); var imports = new List <MemberImport>(); var aspect = new Aspect(type, scope, activation, construction, crosscutting, advices, imports, introductions); advices.AddRange(_adviceBuilder.GetAdvices(aspect)); imports.AddRange(_interTypeBuilder.AddMemberImports(aspect)); introductions.AddRange(_interTypeBuilder.AddMemberIntroductions(aspect)); return(aspect); }