Esempio n. 1
0
        public bool Handle(string evt, Dictionary <string, object> data)
        {
            // check if current state is a (nested) statemachine, if so, give it the event.
            // if it handles the event, stop processing here.
            if (currentState is INestedState)
            {
                INestedState nested = currentState as INestedState;
                if (nested.Handle(evt, data))
                {
                    return(true);
                }
            }

            if (currentState == null)
            {
                return(false);
            }
            if (!currentState.handlers.ContainsKey(evt))
            {
                return(false);
            }

            List <Handler> handlers = currentState.handlers[evt];

            foreach (Handler handler in handlers)
            {
                Transition transition = new Transition(currentState, handler);
                if (transition.performTransition(data))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public List <string> getActiveStateConfiguration()
        {
            List <string> states = new List <string>();

            states.Add(currentState.id);
            if (currentState is INestedState)
            {
                INestedState nested = currentState as INestedState;
                states.AddRange(nested.getActiveStateConfiguration());
            }
            return(states);
        }