/// <summary>
        /// Handles node entry event, which happens before the ENTRY Behavior is executed.
        /// This implementation sets the machine's model's state to the new value given by the entered node.
        /// This inherits thread-safety from the critical sections established around TraverseConnector calls.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override void HandleNodeEntered(object sender, NodeEnteredEventArgs args)
        {
            var changeArgs = GetStateChangedEventArgs(sender, args);

            // Update the StatefulModel, if there is one.
            if (StatefulModel != null)
            {
                StatefulModel.State = changeArgs.NewState;
            }

            // Raise an event for the state entry.
            OnStateEntered(changeArgs);
        }
        private StateChangedEventArgs <TState> GetStateChangedEventArgs(object sender, NodeEnteredEventArgs args)
        {
            var newState   = GetNodeAsState(sender as StateNode);
            var oldState   = GetStringAsState(RequiredPseudoStateValue);
            var changeArgs = new StateChangedEventArgs <TState>()
            {
                NewState = newState, OldState = oldState
            };
            var transition = args.EnteredFrom as UmlTransition;

            if (transition != null && transition.Supplier is StateNode)
            {
                changeArgs.OldState = GetNodeAsState(transition.Supplier as StateNode);
            }
            return(changeArgs);
        }
 protected abstract void HandleNodeEntryBehaviorsFinished(object sender, NodeEnteredEventArgs args);
 protected override void HandleNodeEntryBehaviorsFinished(object sender, NodeEnteredEventArgs args)
 {
     // Raise the state change event now that the behaviors are done.
     OnStateChanged(GetStateChangedEventArgs(sender, args));
 }
 protected abstract void HandleNodeEntered(object sender, NodeEnteredEventArgs args);