Пример #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
        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);
        }