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); }
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); }
protected override bool ShouldBreak(TPipeline pipeline, MethodBoundaryAspect aspect, out IInvocationState <TPipeline> transition) { var flow = pipeline.FlowBehavior; switch (flow) { case FlowBehavior.Return: case FlowBehavior.ThrowException: transition = new FinallyState <TPipeline>(BoundaryAspects.TakeBeforeExclusive(aspect)); break; default: transition = null; break; } return(transition != null); }
/// <summary> /// Возвращает признак того, что необходимо прервать выполнение текущего действия и /// выполнить переход в состояние <paramref name="transition"/>. /// </summary> /// <param name="aspect">Текущий аспект.</param> /// <param name="transition">Состояние, в которое необходимо выполнить переход.</param> /// <param name="pipeline">Пайплайн.</param> /// <returns>Признак того, что необходимо прервать выполнение текущего действия.</returns> protected abstract bool ShouldBreak(TPipeline pipeline, MethodBoundaryAspect aspect, out IInvocationState <TPipeline> transition);
/// <summary> /// Выполняет применение аспекта <paramref name="aspect"/> на пайплайн <paramref name="pipeline"/>. /// </summary> /// <param name="aspect">Аспект.</param> /// <param name="pipeline">Пайплайн.</param> protected abstract void Apply(MethodBoundaryAspect aspect, TPipeline pipeline);
protected override void Apply(MethodBoundaryAspect aspect, TPipeline pipeline) { aspect.OnExit(pipeline); }