internal void ExecuteAction(ActionToken action, object data) { if (actionHandlerDic.TryGetValue(action, out StateActionHandler handler)) { handler(action, data); } }
protected void UnregisterAction(ActionToken action) { if (action == null) { throw new ArgumentNullException("StateBase::UnregisterAction->action is null"); } if (actionHandlerDic.ContainsKey(action)) { actionHandlerDic.Remove(action); } }
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); }