Beispiel #1
0
 protected override void OnActivityChangeAdd(ActivityExecutionContext executionContext, Activity addedActivity)
 {
     if (executionContext == null)
     {
         throw new ArgumentNullException("executionContext");
     }
     if (addedActivity == null)
     {
         throw new ArgumentNullException("addedActivity");
     }
     if (addedActivity.Enabled && (executionContext.Activity.ExecutionStatus == ActivityExecutionStatus.Executing))
     {
         EventDrivenActivity eventDriven = addedActivity as EventDrivenActivity;
         if (eventDriven != null)
         {
             StateMachineSubscriptionManager.ChangeEventDrivenQueueState(executionContext, eventDriven, false);
             StateMachineExecutionState state = StateMachineExecutionState.Get(StateMachineHelpers.GetRootState(executionContext.Activity as StateActivity));
             if (StateMachineHelpers.GetCurrentState(executionContext) != null)
             {
                 state.SubscriptionManager.ReevaluateSubscriptions(executionContext);
                 state.LockQueue();
                 state.ProcessActions(executionContext);
             }
         }
     }
 }
Beispiel #2
0
        protected override void OnActivityChangeAdd(ActivityExecutionContext executionContext, Activity addedActivity)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            if (addedActivity == null)
            {
                throw new ArgumentNullException("addedActivity");
            }

            if (!addedActivity.Enabled)
            {
                return;
            }

            if (executionContext.Activity.ExecutionStatus != ActivityExecutionStatus.Executing)
            {
                return; // activity is not executing
            }
            EventDrivenActivity eventDriven = addedActivity as EventDrivenActivity;

            if (eventDriven == null)
            {
                return;
            }

            // Activity we added is an EventDrivenActivity

            // First we disable the queue
            StateMachineSubscriptionManager.ChangeEventDrivenQueueState(executionContext, eventDriven, false);
            StateActivity rootState = StateMachineHelpers.GetRootState(executionContext.Activity as StateActivity);
            StateMachineExecutionState executionState = StateMachineExecutionState.Get(rootState);
            StateActivity currentState = StateMachineHelpers.GetCurrentState(executionContext);

            if (currentState == null)
            {
                return; // Dynamic update happened before we entered the initial state
            }
            StateMachineSubscriptionManager subscriptionManager = executionState.SubscriptionManager;

            subscriptionManager.ReevaluateSubscriptions(executionContext);
            executionState.LockQueue();
            executionState.ProcessActions(executionContext);
        }