コード例 #1
0
        void Transition(Composer composer, TInstance instance)
        {
            composer.Execute(() =>
            {
                State <TInstance> currentState = _currentStateAccessor.Get(instance);
                if (_toState.Equals(currentState))
                {
                    return(composer.ComposeCompleted());
                }

                var taskComposer = new TaskComposer <TInstance>(composer.CancellationToken);

                if (currentState != null)
                {
                    currentState.Raise(taskComposer, instance, currentState.Leave);
                }

                _toState.Raise(taskComposer, instance, _toState.BeforeEnter, currentState);

                ((Composer)taskComposer).Execute(() => _currentStateAccessor.Set(instance, _toState));

                if (currentState != null)
                {
                    currentState.Raise(taskComposer, instance, currentState.AfterLeave, _toState);
                }

                _toState.Raise(taskComposer, instance, _toState.Enter);

                return(taskComposer.Finish());
            });
        }
コード例 #2
0
        void Activity <TInstance, TData> .Execute(Composer composer, TInstance instance, TData value)
        {
            composer.Execute(() =>
            {
                if (_filterExpression(value) == false)
                {
                    return(composer.ComposeCompleted());
                }

                return(composer.ComposeActivity(_activity, instance, value));
            });
        }
コード例 #3
0
        void Execute(Composer composer, TInstance instance)
        {
            composer.Execute(() =>
            {
                CompositeEventStatus value = _property.Get(instance);
                value.Set(_flag);

                _property.Set(instance, value);

                if (!value.Equals(_complete))
                {
                    return(composer.ComposeCompleted());
                }

                var taskComposer = new TaskComposer <TInstance>(composer.CancellationToken);

                _completeCallback(taskComposer, instance);

                return(taskComposer.Finish());
            });
        }