Beispiel #1
0
        /// <summary>
        /// Process exit event
        /// </summary>
        /// <param name="destinationState">Specifies destination state</param>
        internal void Exit(MartyState destinationState)
        {
            // Start event processing.
            this.ProcessingHandler(true);

            // Block transitioning.
            this.BlockTransitionHandler();

            MartyState parentState = this.StateLookupHandler(this.ParentState);

            // Check if destination state is a descendant of this state.
            if (!this.IsDescendant(destinationState))
            {
                // Process this state's exit event.
                this.EventHandler(MartyBase.Exit, null);

                // Check if this state's parent needs to process its exit event.
                if (!(this.ParentState == null || parentState.IsTopState || this.IsSibling(destinationState)))
                {
                    // Process parent's exit event.
                    parentState.EventHandler(MartyBase.Exit, null);
                }
            }

            // Stop event processing.
            this.ProcessingHandler(false);
        }
Beispiel #2
0
        /// <summary>
        /// Performs entry action
        /// </summary>
        /// <param name="source">Specifies source state</param>
        internal void Enter(MartyState source)
        {
            // Mark that the event is being processed.
            this.ProcessingHandler(true);

            MartyState parentState = this.StateLookupHandler(this.ParentState);

            // Check if parent's entry event needs processing.
            if (!(null == parentState || parentState.IsTopState || source.IsAncestor(parentState) || this.IsDescendant(source)))
            {
                // Process parent's entry event.
                parentState.EventHandler(MartyBase.Entry, null);
            }

            // Check if source is NOT a descendant.
            if (!this.IsDescendant(source))
            {
                // Process
                this.EventHandler(MartyBase.Entry, null);
            }

            // Release processing.
            this.ProcessingHandler(false);
        }