Inheritance: NCop.Aspects.Aspects.AspectAttribute
Ejemplo n.º 1
0
        public Func<IAspectDefinition, IAspectExpressionBuilder> Visit(OnMethodBoundaryAspectAttribute aspect)
        {
            return aspectDefinition => {
                Func<IAspectExpression, IAspectExpression> ctor = null;
                var _topAspectInScopeDefinition = topAspectInScopeDefinition;
                var methodAspectDefinition = aspectDefinition as IMethodAspectDefinition;

                if (lastAspect.Top) {
                    ctor = expression => {
                        return new TopOnMethodBoundaryAspectExpression(expression, methodAspectDefinition);
                    };

                    lastAspect = new Aspect();
                }
                else {
                    if (lastAspect.IsInBinding) {
                        if (lastAspect.IsTopBinding) {
                            lastAspect.IsTopBinding = false;

                            ctor = expression => {
                                return new TopBindingOnMethodBoundaryAspectExpression(expression, methodAspectDefinition);
                            };
                        }
                        else {
                            ctor = expression => {
                                return new BindingOnMethodBoundaryAspectExpression(expression, methodAspectDefinition, _topAspectInScopeDefinition);
                            };
                        }
                    }
                    else {
                        ctor = expression => {
                            return new NestedOnMethodBoundaryAspectExpression(expression, methodAspectDefinition);
                        };
                    }
                }

                topAspectInScopeDefinition = aspectDefinition;

                return new AspectNodeExpressionBuilder(ctor);
            };
        }
 internal OnMethodBoundaryAspectDefinition(OnMethodBoundaryAspectAttribute aspect, Type aspectDeclaringType, MethodInfo method, MemberInfo target)
     : base(aspect, aspectDeclaringType, method, target)
 {
     this.aspect = aspect;
 }