// Recursively goes up the the state hierarchy until a state is found // that will handle the event. private TransitionResult Dispatch(State origin, int eventID, object[] args) { TransitionResult transResult = notFiredResult; // If there are any Transitions for this event. if (transitions[eventID] != null) { // Iterate through the Transitions until one of them fires. foreach (Transition trans in transitions[eventID]) { transResult = trans.Fire(origin, args); if (transResult.HasFired) { // Break out of loop. We're finished. break; } } } // Else if there are no Transitions for this event and there is a // superstate. else if (Superstate != null) { // Dispatch the event to the superstate. transResult = Superstate.Dispatch(origin, eventID, args); } return(transResult); }
// Enters the state in via its history in shallow mode. private TransitionResult dispatch(EventContext context) { var transResult = s_notFiredResult; // If there are any Transitions for this event. if (m_transitions[context.CurrentEvent] != null) { // Iterate through the Transitions until one of them fires. foreach (var trans in m_transitions[context.CurrentEvent]) { transResult = trans.fire(context); if (transResult.HasFired) { // Break out of loop. We're finished. return(transResult); } } } // Else if there are no Transitions for this event and there is a // superstate. if (Superstate != null) { // Dispatch the event to the superstate. transResult = Superstate.dispatch(context); } return(transResult); }
public bool TryFindHandler(TTrigger trigger, object[] args, out TriggerBehaviourResult handler) { TriggerBehaviourResult superStateHandler = null; bool handlerFound = (TryFindLocalHandler(trigger, args, out TriggerBehaviourResult localHandler) || (Superstate != null && Superstate.TryFindHandler(trigger, args, out superStateHandler))); // If no handler for super state, replace by local handler (see issue #398) handler = superStateHandler ?? localHandler; return(handlerFound); }
public IEnumerable <TTrigger> GetPermittedTriggers(params object[] args) { var result = TriggerBehaviours .Where(t => t.Value.Any(a => !a.UnmetGuardConditions(args).Any())) .Select(t => t.Key); if (Superstate != null) { result = result.Union(Superstate.GetPermittedTriggers(args)); } return(result); }
public void Exit(Transition transition) { Enforce.ArgumentNotNull(transition, nameof(transition)); if (transition.IsReentry) { ExecuteExitActions(transition); } else if (!Includes(transition.Destination)) { ExecuteExitActions(transition); Superstate?.Exit(transition); } }
public void Enter(Transition transition, params object[] entryArgs) { Enforce.ArgumentNotNull(transition, nameof(transition)); if (transition.IsReentry) { ExecuteEntryActions(transition, entryArgs); } else if (!Includes(transition.Source)) { Superstate?.Enter(transition, entryArgs); ExecuteEntryActions(transition, entryArgs); } }
public void Exit(Transition transition) { Enforce.ArgumentNotNull(transition, "transtion"); if (transition.IsReentry) { ExecuteExitActions(transition); } else if (!Includes(transition.Destination)) { ExecuteExitActions(transition); if (Superstate != null) { Superstate.Exit(transition); } } }
public void Enter(Transition transition, params object[] entryArgs) { Enforce.ArgumentNotNull(transition, "transtion"); if (transition.IsReentry) { ExecuteEntryActions(transition, entryArgs); } else if (!Includes(transition.Source)) { if (Superstate != null) { Superstate.Enter(transition, entryArgs); } ExecuteEntryActions(transition, entryArgs); } }
public bool TryFindHandlerWithUnmetGuardCondition(TTrigger trigger, out TriggerBehaviour handler) { return(TryFindLocalHandler(trigger, out handler, t => !t.IsGuardConditionMet) || (Superstate != null && Superstate.TryFindHandlerWithUnmetGuardCondition(trigger, out handler))); }
public bool TryFindHandler(TTrigger trigger, out TriggerBehaviour handler) { return(TryFindLocalHandler(trigger, out handler) || Superstate != null && Superstate.TryFindHandler(trigger, out handler)); }
public bool IsIncludedIn(TState state) { return (UnderlyingState.Equals(state) || Superstate != null && Superstate.IsIncludedIn(state)); }
public bool TryFindHandler(TTrigger trigger, object[] args, out TriggerBehaviourResult handler) { return(TryFindLocalHandler(trigger, args, out handler) || (Superstate != null && Superstate.TryFindHandler(trigger, args, out handler))); }
public bool HasHandlerFor(TTriggerType trigger, out TriggerStrategy handler) { return(HasLocalHandlerFor(trigger, out handler) || (Superstate != null && Superstate.HasHandlerFor(trigger, out handler))); }