public static bool IsInState <TInternalState>(IMachineState <TInternalState> internalState, MachineDefinition <TInternalState> machineDefinition, State state) { return(Misc <TInternalState> .FindAllStates(machineDefinition.ParentStates, internalState.CurrentState) .Any(currentState => currentState.Name == state.Name)); }
public static void Dispatch <TInternalState, TEvent>(MachineDefinition <TInternalState> machineDefinition , IMachineState <TInternalState> machineState , TEvent evnt) { var lookUp = Find(machineDefinition); Dispatch(evnt , machineState , machineState.CurrentState , machineDefinition.ParentStates , machineDefinition.EventInterceptors , machineDefinition.Config , true , lookUp); }
public static void Start <TInternalState>(MachineDefinition <TInternalState> machineDefinition , IMachineState <TInternalState> internalState) { Dispatch(machineDefinition, internalState, new Events.EntryEvent()); }
private static Func <string, InternalState <TInternalState> > Find <TInternalState> (MachineDefinition <TInternalState> machineDefinition) { return((name) => machineDefinition.LookupRegisteredState(name)); }
/// <summary> /// Returns a list of of the Events that the state machine will currently perform an action on. /// </summary> /// <typeparam name="TInternalState"></typeparam> /// <param name="internalState"></param> /// <param name="machineDefinition"></param> /// <returns>Will not return Events.EntryEvents or exit Events.ExitEvent events</returns> public static IEnumerable <Type> CurrentlyActionableEvents <TInternalState>(IMachineState <TInternalState> internalState, MachineDefinition <TInternalState> machineDefinition) { return(Misc <TInternalState> .FindAllStates(machineDefinition.ParentStates, internalState.CurrentState) .SelectMany(x => x.Handlers) .Select(x => x.Key) .Where(x => x != typeof(Events.EntryEvent)) .Where(x => x != typeof(Events.ExitEvent)) .Distinct() .ToList()); }
public static IEnumerable <InternalState <TInternalState> > CurrentStates <TInternalState>(IMachineState <TInternalState> internalState, MachineDefinition <TInternalState> machineDefinition) { return(Misc <TInternalState> .FindAllStates(machineDefinition.ParentStates, internalState.CurrentState)); }