public void Save(IStateMachineSaver <TState> stateMachineSaver) { Guard.AgainstNullArgument("stateMachineSaver", stateMachineSaver); stateMachineSaver.SaveCurrentState(this.currentState != null ? new Initializable <TState> { Value = this.currentState.Id } : new Initializable <TState>()); IEnumerable <IState <TState, TEvent> > superStatesWithLastActiveState = this.states.GetStates() .Where(s => s.SubStates.Any()) .Where(s => s.LastActiveState != null) .ToList(); var historyStates = superStatesWithLastActiveState.ToDictionary( s => s.Id, s => s.LastActiveState.Id); stateMachineSaver.SaveHistoryStates(historyStates); }
/// <summary> /// Saves the current state and history states to a persisted state. Can be restored using <see cref="Load"/>. /// </summary> /// <param name="stateMachineSaver">Data to be persisted is passed to the saver.</param> public void Save(IStateMachineSaver <TState> stateMachineSaver) { Ensure.ArgumentNotNull(stateMachineSaver, "stateMachineSaver"); this.stateMachine.Save(stateMachineSaver); }
/// <summary> /// Saves the current state and history states to a persisted state. Can be restored using <see cref="Load"/>. /// </summary> /// <param name="stateMachineSaver">Data to be persisted is passed to the saver.</param> public void Save(IStateMachineSaver <TState> stateMachineSaver) { Guard.AgainstNullArgument("stateMachineSaver", stateMachineSaver); this.stateMachine.Save(stateMachineSaver); }