예제 #1
0
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            //clean up
            this.internalStates.Clear();
            this.internalStateFuncs.Clear();
            this.internalTransitions.Clear();

            StateMachineHelper.ProcessChildStates(metadata, this.States, this.internalStates, this.internalStateFuncs);

            if (this.Entry != null)
            {
                metadata.AddChild(this.Entry);
            }
            if (this.Exit != null)
            {
                metadata.AddChild(this.Exit);
            }

            ProcessTransitions(metadata);

            metadata.AddArgument(new RuntimeArgument("ToState", this.ToState.ArgumentType, ArgumentDirection.In));
            metadata.AddArgument(new RuntimeArgument("EventManager", this.EventManager.ArgumentType, ArgumentDirection.In));

            metadata.AddImplementationVariable(this.currentRunningTriggers);
            metadata.AddImplementationVariable(this.hasRunningChildState);
            metadata.AddImplementationVariable(this.isExiting);
            metadata.AddImplementationVariable(this.evaluateConditionBookmark);
            metadata.AddImplementationVariable(this.completeStateBookmark);
        }
예제 #2
0
        /// <summary>
        /// Do validation and if validation is successful, create internal representations for states and transitions.
        /// </summary>
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            //cleanup
            this.internalStateFuncs.Clear();
            this.internalStates.Clear();

            //clear Ids and Flags via transitions
            this.PassNumber++;
            TraverseViaTransitions(ClearState, ClearTransition);
            //clear Ids and Flags via children
            this.PassNumber++;
            TraverseViaChildren(ClearStates, null, ClearTransitions, false);

            //Mark via children and do some check
            this.PassNumber++;
            TraverseViaChildren(MarkStatesViaChildren,
                                delegate(State state) { StateCannotHaveMultipleParents(metadata, state); }, null, false);

            this.PassNumber++;
            //Mark via transition
            TraverseViaTransitions(delegate(State state) { MarkStateViaTransition(metadata, state); }, null);

            //Do validation via children
            //need not check the violation of state which is not reached
            this.PassNumber++;
            TraverseViaChildren(delegate(Collection <State> states) { ValidateStates(metadata, states); }, null,
                                delegate(State state) { ValidateTransitions(metadata, state); }, true);

            //Validate the root state machine itself
            ValidateStateMachine(metadata);

            if (!metadata.HasViolations)
            {
                StateMachineHelper.ProcessChildStates(metadata, this.States, this.internalStates, this.internalStateFuncs);
            }
            metadata.AddImplementationVariable(this.eventManager);
            foreach (Variable variable in this.Variables)
            {
                metadata.AddVariable(variable);
            }
        }