Пример #1
0
        protected override bool ShouldBreak(TPipeline pipeline, MethodBoundaryAspect aspect, out IInvocationState <TPipeline> transition)
        {
            var flow = pipeline.FlowBehavior;

            switch (flow)
            {
            // OnEntry -> Return(value) -> OnSuccess [only executed] -> OnExit [only executed]
            case FlowBehavior.Return:
                transition = new SuccessState <TPipeline>(BoundaryAspects.TakeBeforeExclusive(aspect));
                break;

            // OnEntry -> Throw(exception) -> OnExit [only executed]
            case FlowBehavior.ThrowException:
                transition = new FinallyState <TPipeline>(BoundaryAspects.TakeBeforeExclusive(aspect));
                break;

            // OnEntry -> Rethrow(exception) -> OnException [all except current] -> {maybe: OnSuccess} -> OnExit
            case FlowBehavior.RethrowException:
                transition = new CatchState <TPipeline>(BoundaryAspects)
                {
                    IgnoredAspects = new[] { aspect }
                };
                break;

            // OnEntry -> ContinueFaulted(value) -> OnSuccess [all] -> OnExit
            case FlowBehavior.UpdateReturnValue:
                transition = new SuccessState <TPipeline>(BoundaryAspects);
                break;

            default:
                transition = null; break;
            }

            return(transition != null);
        }
Пример #2
0
        protected override bool ShouldBreak(TPipeline pipeline, MethodBoundaryAspect aspect, out IInvocationState <TPipeline> transition)
        {
            var flow = pipeline.FlowBehavior;

            switch (flow)
            {
            // OnEntry -> MethodCall [exception] -> Catch [return] -> OnSuccess [only executed]
            // для уже выполнившихся до Return аспектов должно казаться что метод выполнился без
            // ошибок и вернул результат.
            case FlowBehavior.Return:
                transition = new SuccessState <TPipeline>(BoundaryAspects.TakeBeforeExclusive(aspect));
                break;

            case FlowBehavior.ThrowException:
                transition = new FinallyState <TPipeline>(BoundaryAspects.TakeBeforeExclusive(aspect));
                break;

            // OnEntry -> MethodCall [exception] -> Catch [Swallow] -> OnSuccess [all except executed]
            case FlowBehavior.UpdateReturnValue:
                transition = new SuccessState <TPipeline>(BoundaryAspects)
                {
                    IgnoredAspects = BoundaryAspects.TakeBeforeInclusive(aspect)
                                     .ToArray()
                };
                break;

            default:
                transition = null;
                break;
            }

            return(transition != null);
        }