コード例 #1
0
        public Aspect Build(Type type)
        {
            var aspectAttribute = type.GetCustomAttributes <AspectAttribute> (true).SingleOrDefault();

            Assertion.IsNotNull(aspectAttribute);

            var construction = new TypeConstruction(type);
            var pointcut     = _pointcutBuilder.Build(type);

            return(Build(type, aspectAttribute, construction, pointcut));
        }
コード例 #2
0
        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));
            }
        }