public static void Execute <TPipeline>(
            [NotNull] TPipeline pipeline,
            [NotNull] IInvocationState <TPipeline> initialState)
            where TPipeline : InvocationPipelineBase
        {
            var nextState = initialState.MakeTransition(pipeline);

            while (nextState != null)
            {
                nextState = nextState.MakeTransition(pipeline);
            }
        }
Exemple #2
0
 /// <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);
Exemple #3
0
        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>
 /// Инициализирует экземпляр <see cref="AsyncInvocationStateSyncAdapter{TPipeline}"/>.
 /// </summary>
 /// <param name="invocationState">Состояние вызова.</param>
 public AsyncInvocationStateSyncAdapter(IInvocationState <TPipeline> invocationState)
 {
     _invocationState = invocationState;
 }
Exemple #5
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);
        }
Exemple #6
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);
        }