public CompositeState Reduce(CompositeState state, IAction action) { if (action is UpdateTimeAction) { state.LastTime = ((UpdateTimeAction)action).NewTime; } if (action is UpdateGuidAction) { state.RandomGuid = new Random().Next(0, 2) == 1 ? ((UpdateGuidAction)action).Guid : state.RandomGuid; } if (action is UpdateSubstateMessageAction) { state.SubState.SubStateMessage = ((UpdateSubstateMessageAction)action).Message; } if (action is UpdateSubstateTimeAction) { state.SubState.SubStateTime = ((UpdateSubstateTimeAction)action).NewTime; } return(state); }
public IAction Execute(CompositeState state, IAction action) { Console.WriteLine(action.GetType()); return(NullAction.Instance); }