Beispiel #1
0
        private static void EnteringLeafState(ActivityExecutionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            StateActivity state = (StateActivity)context.Activity;

            Debug.Assert(StateMachineHelpers.IsLeafState(state));

            StateMachineExecutionState executionState = GetExecutionState(state);

            executionState.SubscriptionManager.SubscribeToSetStateEvent(context);

            string completedStateName = StateMachineHelpers.GetCompletedStateName(state);

            if (StateMachineHelpers.IsCompletedState(state))
            {
                // make sure that we track that we entered the completed state
                EnteringStateAction enteringState = new EnteringStateAction(state.QualifiedName);
                executionState.EnqueueAction(enteringState);
                executionState.ProcessActions(context);

                // this is the final state, so we start completing this tree
                executionState.Completed = true;
                LeavingState(context);
            }
            else
            {
                if (String.IsNullOrEmpty(executionState.NextStateName))
                {
                    executionState.SubscriptionManager.ReevaluateSubscriptions(context);
                    EnteringStateAction enteringState = new EnteringStateAction(state.QualifiedName);
                    executionState.EnqueueAction(enteringState);
                    executionState.LockQueue();
                }
                else
                {
                    // The StateInitialization requested a state transtion
                    EnteringStateAction enteringState = new EnteringStateAction(state.QualifiedName);
                    executionState.EnqueueAction(enteringState);
                    executionState.ProcessTransitionRequest(context);
                }
                executionState.ProcessActions(context);
            }
        }
Beispiel #2
0
        private static void EnteringLeafState(ActivityExecutionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            StateActivity activity = (StateActivity)context.Activity;
            StateMachineExecutionState executionState = GetExecutionState(activity);

            executionState.SubscriptionManager.SubscribeToSetStateEvent(context);
            StateMachineHelpers.GetCompletedStateName(activity);
            if (StateMachineHelpers.IsCompletedState(activity))
            {
                EnteringStateAction action = new EnteringStateAction(activity.QualifiedName);
                executionState.EnqueueAction(action);
                executionState.ProcessActions(context);
                executionState.Completed = true;
                LeavingState(context);
            }
            else
            {
                if (string.IsNullOrEmpty(executionState.NextStateName))
                {
                    executionState.SubscriptionManager.ReevaluateSubscriptions(context);
                    EnteringStateAction action2 = new EnteringStateAction(activity.QualifiedName);
                    executionState.EnqueueAction(action2);
                    executionState.LockQueue();
                }
                else
                {
                    EnteringStateAction action3 = new EnteringStateAction(activity.QualifiedName);
                    executionState.EnqueueAction(action3);
                    executionState.ProcessTransitionRequest(context);
                }
                executionState.ProcessActions(context);
            }
        }