private void TraverseViaTransitions(Action <System.Activities.Statements.State> actionForState, Action <Transition> actionForTransition)
        {
            Stack <System.Activities.Statements.State> stack = new Stack <System.Activities.Statements.State>();

            stack.Push(this.InitialState);
            uint passNumber = this.PassNumber;

            while (stack.Count > 0)
            {
                System.Activities.Statements.State state = stack.Pop();
                if ((state != null) && (state.PassNumber != passNumber))
                {
                    state.PassNumber = passNumber;
                    if (actionForState != null)
                    {
                        actionForState(state);
                    }
                    foreach (Transition transition in state.Transitions)
                    {
                        if (actionForTransition != null)
                        {
                            actionForTransition(transition);
                        }
                        stack.Push(transition.To);
                    }
                }
            }
        }
 private static void ClearTransitions(System.Activities.Statements.State state)
 {
     foreach (Transition transition in state.Transitions)
     {
         ClearTransition(transition);
     }
 }
 private static void MarkTransitionsInState(System.Activities.Statements.State state)
 {
     if (state.Transitions.Count > 0)
     {
         for (int i = 0; i < state.Transitions.Count; i++)
         {
             Transition transition = state.Transitions[i];
             if (!string.IsNullOrEmpty(state.StateId))
             {
                 transition.Id = StateMachineIdHelper.GenerateTransitionId(state.StateId, i);
             }
         }
     }
 }
Exemplo n.º 4
0
 public InternalState(System.Activities.Statements.State state)
 {
     this.state                            = state;
     base.DisplayName                      = state.DisplayName;
     this.onEntryComplete                  = new CompletionCallback(this.OnEntryComplete);
     this.onTriggerComplete                = new CompletionCallback(this.OnTriggerComplete);
     this.onConditionComplete              = new CompletionCallback <bool>(this.OnConditionComplete);
     this.onExitComplete                   = new CompletionCallback(this.OnExitComplete);
     this.evaluateConditionCallback        = new BookmarkCallback(this.StartEvaluateCondition);
     this.currentRunningTriggers           = new Variable <int>();
     this.isExiting                        = new Variable <bool>();
     this.evaluateConditionBookmark        = new Variable <Bookmark>();
     this.internalTransitions              = new Collection <InternalTransition>();
     this.triggerInternalTransitionMapping = new Dictionary <Activity, InternalTransition>();
 }
 private void MarkStatesViaChildren(NativeActivityMetadata metadata, Collection <System.Activities.Statements.State> states)
 {
     if (states.Count > 0)
     {
         for (int i = 0; i < states.Count; i++)
         {
             System.Activities.Statements.State state = states[i];
             if (string.IsNullOrEmpty(state.StateId))
             {
                 state.StateId          = StateMachineIdHelper.GenerateStateId("0", i);
                 state.StateMachineName = base.DisplayName;
             }
             else
             {
                 bool isWarning = false;
                 metadata.AddValidationError(new ValidationError(System.Activities.SR.StateCannotBeAddedTwice(state.DisplayName), isWarning));
             }
         }
     }
 }
 private static void ValidateState(NativeActivityMetadata metadata, System.Activities.Statements.State state)
 {
     if (state.Reachable)
     {
         if (state.IsFinal)
         {
             if (state.Exit != null)
             {
                 bool isWarning = false;
                 metadata.AddValidationError(new ValidationError(System.Activities.SR.FinalStateCannotHaveProperty(state.DisplayName, "Exit"), isWarning));
             }
             if (state.Transitions.Count > 0)
             {
                 bool flag2 = false;
                 metadata.AddValidationError(new ValidationError(System.Activities.SR.FinalStateCannotHaveTransition(state.DisplayName), flag2));
             }
         }
         else if (state.Transitions.Count == 0)
         {
             bool flag3 = false;
             metadata.AddValidationError(new ValidationError(System.Activities.SR.SimpleStateMustHaveOneTransition(state.DisplayName), flag3));
         }
     }
 }
 private static void ClearState(System.Activities.Statements.State state)
 {
     state.StateId   = null;
     state.Reachable = false;
     state.ClearInternalState();
 }
        private static void ValidateTransitions(NativeActivityMetadata metadata, System.Activities.Statements.State currentState)
        {
            Collection <Transition> transitions = currentState.Transitions;
            HashSet <Activity>      set         = new HashSet <Activity>();
            Dictionary <Activity, List <Transition> > dictionary = new Dictionary <Activity, List <Transition> >();

            foreach (Transition transition in transitions)
            {
                if (transition.Source != null)
                {
                    bool isWarning = false;
                    metadata.AddValidationError(new ValidationError(System.Activities.SR.TransitionCannotBeAddedTwice(transition.DisplayName, currentState.DisplayName, transition.Source.DisplayName), isWarning));
                }
                else
                {
                    transition.Source = currentState;
                    if (transition.To == null)
                    {
                        bool flag2 = false;
                        metadata.AddValidationError(new ValidationError(System.Activities.SR.TransitionTargetCannotBeNull(transition.DisplayName, currentState.DisplayName), flag2));
                    }
                    else if (string.IsNullOrEmpty(transition.To.StateId))
                    {
                        bool flag3 = false;
                        metadata.AddValidationError(new ValidationError(System.Activities.SR.StateNotBelongToAnyParent(transition.DisplayName, transition.To.DisplayName), flag3));
                    }
                    Activity activeTrigger = transition.ActiveTrigger;
                    if (transition.Condition == null)
                    {
                        if (!dictionary.ContainsKey(activeTrigger))
                        {
                            dictionary.Add(activeTrigger, new List <Transition>());
                        }
                        dictionary[activeTrigger].Add(transition);
                    }
                    else
                    {
                        set.Add(activeTrigger);
                    }
                }
            }
            foreach (KeyValuePair <Activity, List <Transition> > pair in dictionary)
            {
                if (set.Contains(pair.Key) || (pair.Value.Count > 1))
                {
                    foreach (Transition transition2 in pair.Value)
                    {
                        if (transition2.Trigger != null)
                        {
                            bool flag4 = false;
                            metadata.AddValidationError(new ValidationError(System.Activities.SR.UnconditionalTransitionShouldNotShareTriggersWithOthers(transition2.DisplayName, currentState.DisplayName, transition2.Trigger.DisplayName), flag4));
                        }
                        else
                        {
                            bool flag5 = false;
                            metadata.AddValidationError(new ValidationError(System.Activities.SR.UnconditionalTransitionShouldNotShareNullTriggersWithOthers(transition2.DisplayName, currentState.DisplayName), flag5));
                        }
                    }
                }
            }
        }
 private static void MarkStateViaTransition(System.Activities.Statements.State state)
 {
     state.Reachable = true;
 }