public AbstractEnterExitStateHandler Pop()
        {
            AbstractEnterExitStateHandler result = activeStateHandler;

            activeStateHandler = null;
            return(result);
        }
 public void Push(AbstractEnterExitStateHandler stateHandler)
 {
     if (activeStateHandler != null)
     {
         Pop().OnExit();
     }
     activeStateHandler = stateHandler;
 }
 public void OnStateChanged(string state)
 {
     if (state == HandledState && !isInHandledState)
     {
         isInHandledState = true;
         exitHandler.Push(this);
         OnEnter();
     }
     else if (state != HandledState && isInHandledState)
     {
         isInHandledState = false;
         AbstractEnterExitStateHandler abstractEnterExitStateHandler = exitHandler.Pop();
         if (abstractEnterExitStateHandler == this)
         {
             OnExit();
         }
     }
 }