コード例 #1
0
 internal void ExecuteAction(ActionToken action, object data)
 {
     if (actionHandlerDic.TryGetValue(action, out StateActionHandler handler))
     {
         handler(action, data);
     }
 }
コード例 #2
0
 protected void UnregisterAction(ActionToken action)
 {
     if (action == null)
     {
         throw new ArgumentNullException("StateBase::UnregisterAction->action is null");
     }
     if (actionHandlerDic.ContainsKey(action))
     {
         actionHandlerDic.Remove(action);
     }
 }
コード例 #3
0
ファイル: StateMachine.cs プロジェクト: mengtest/RewriteFrame
        public void PerformAction(ActionToken action, object data)
        {
            if (action == null)
            {
                throw new ArgumentNullException("StateMachine::PreformAction->actoin is null");
            }

            if (CurrentState == null)
            {
                throw new InvalidOperationException("StateMachine::PreformAction->CurrentState is null");
            }

            CurrentState.ExecuteAction(action, data);
        }
コード例 #4
0
        protected void RegisterAction(ActionToken action, StateActionHandler actionHandler)
        {
            if (action == null)
            {
                throw new ArgumentNullException("StateBase::RegisterAction->action is null");
            }

            if (actionHandler == null)
            {
                throw new ArgumentNullException("StateBase::RegisterAction->actionHandler is null");
            }

            if (actionHandlerDic.ContainsKey(action))
            {
                throw new InvalidOperationException($"Action has been registered.action = {action}.");
            }
            actionHandlerDic.Add(action, actionHandler);
        }
コード例 #5
0
ファイル: StateMachine.cs プロジェクト: mengtest/RewriteFrame
 public void PerformAction(ActionToken action)
 {
     PerformAction(action, null);
 }