Example #1
0
        private void ProcessTransition(Type stateType, object[] data)
        {
            var newStateName = stateType.Namespace + "." + stateType.Name;

            _logger.Info("Transition: " + newStateName);
            var newState = _stateBag.Get(this, newStateName);

            if (newState == null)
            {
                _logger.Warn(newStateName + ": Unknown state!");
                OnUnknownState(newStateName);
                return;
            }

            OnTransition(newState);

            if (State != null && _dispatcher.CanSend(State, "StateExit"))
            {
                _dispatcher.Send(State, "StateExit");
            }

            if (_dispatcher.CanSend(newState, "StateEnter", this))
            {
                var args = new List <object>();
                args.Add(this);
                if (data != null)
                {
                    args.AddRange(data);
                }

                _dispatcher.Send(newState, "StateEnter", args.ToArray());
            }
            State = newState;
        }
Example #2
0
 public bool CanSend(object target, string methodName, params object[] args)
 {
     return(_baseDispatcher.CanSend(target, methodName, args));
 }