Exemple #1
0
 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));
 }
Exemple #2
0
        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);
        }
Exemple #3
0
 public static void Start <TInternalState>(MachineDefinition <TInternalState> machineDefinition
                                           , IMachineState <TInternalState> internalState)
 {
     Dispatch(machineDefinition, internalState, new Events.EntryEvent());
 }
Exemple #4
0
 private static Func <string, InternalState <TInternalState> > Find <TInternalState>
     (MachineDefinition <TInternalState> machineDefinition)
 {
     return((name) => machineDefinition.LookupRegisteredState(name));
 }
Exemple #5
0
 /// <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());
 }
Exemple #6
0
 public static IEnumerable <InternalState <TInternalState> > CurrentStates <TInternalState>(IMachineState <TInternalState> internalState, MachineDefinition <TInternalState> machineDefinition)
 {
     return(Misc <TInternalState> .FindAllStates(machineDefinition.ParentStates, internalState.CurrentState));
 }