public void MethodWithOneParameterAndNoReturnType_DecoratedWithOnFunctionInterceptionAspectWithOneAReturnTypeThatIsTheSameUnderlyingTypeAsTheParameterOfTheMethod_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithIntParamAndNoReturnType"); var aspect = new MethodInterceptionAspectAttribute(typeof(TestFunctionInterceptionAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithoutReturnType_DecoratedWithActionInterceptionAspectWithNewMethodOfOnInvokeThatHasMoreThenOneArgument_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithoutParams"); var aspect = new MethodInterceptionAspectAttribute(typeof(TestInterceptionAspectWithNewMethodOfOnInvokeThatHasMoreThenOneArgument)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void ParameterslessMethodWithReturnType_DecoratedWithOnActionInterceptionAspectWithOneArgumentThatHasTheSameUnderlyingTypeAsTheReturnTypeOfTheMethod_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithoutParamsWithBoolReturnType"); var aspect = new MethodInterceptionAspectAttribute(typeof(TestAspect5)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithOneArgumentAndWithoutReturnType_DecoratedWithFunctionAspectThatHasOneArgumentWhichIsTheSameTypeOfTheMethodsArgument_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithIntParamAndNoReturnType"); var aspect = new MethodInterceptionAspectAttribute(typeof(TestFunctionInterceptionAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodInterceptionAspectAttribute_GivenAnOnMethodBoundaryAspectTypeAsAnArgument_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new MethodInterceptionAspectAttribute(typeof(TestAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(MethodInterceptionAspectAttribute aspect) { return(aspectDefinition => { Func <IAspectExpression, IAspectExpression> ctor = null; var _topAspectInScopeDefinition = (IMethodAspectDefinition)topAspectInScopeDefinition; var methodAspectDefinition = aspectDefinition as IMethodAspectDefinition; if (lastAspect.Top) { ctor = expression => { return new TopMethodInterceptionAspectExpression(expression, methodAspectDefinition); }; lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { if (lastAspect.IsTopBinding) { lastAspect.IsTopBinding = false; ctor = expression => { return new TopBindingMethodInterceptionAspectExpression(expression, methodAspectDefinition); }; } else { ctor = expression => { return new BindingMethodInterceptionAspectExpression(expression, methodAspectDefinition, _topAspectInScopeDefinition); }; } } else { ctor = expression => { return new NestedMethodInterceptionAspectExpression(expression, methodAspectDefinition, _topAspectInScopeDefinition); }; } } lastAspect.IsInBinding = true; lastAspect.IsTopBinding = true; topAspectInScopeDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }); }
public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(MethodInterceptionAspectAttribute aspect) { return((IAspectDefinition aspectDefinition) => { Func <IAspectExpression, IAspectExpression> ctor = null; if (lastAspect.Top) { ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new TopMethodInterceptionAspectExpression(expression, aspectDefinition); }); lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new BindingMethodInterceptionAspectExpression(expression, aspectDefinition); }); } else { var _previousAspectDefinition = previousAspectDefinition; ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new NestedMethodInterceptionAspectExpression(expression, aspectDefinition, _previousAspectDefinition); }); } } lastAspect.IsInBinding = true; previousAspectDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }); }
internal MethodInterceptionAspectDefinition(MethodInterceptionAspectAttribute aspect, Type aspectDeclaringType, MemberInfo member) : base(aspect, aspectDeclaringType, member) { this.aspect = aspect; }