public void Register(StateCondition stateCondition, MicrowaveTrigger trigger, IStateChanger stateChanger) { var key = new StateKey { InitialStateCondition = stateCondition, Trigger = trigger }; Add(key, stateChanger); }
private static void RegisterStateManagerTriggerChanges(StateManager stateManager) { var initialCondition = new StateCondition { IsDoorOpen = false, IsLightOn = false, IsHeaterOn = false, IsButtonPressed = false, IsTimerOn = false }; var doorOpenCondition = new StateCondition { IsDoorOpen = true, IsLightOn = true, IsHeaterOn = false, IsButtonPressed = false, IsTimerOn = false, }; var buttonIsPressedCondition = new StateCondition { IsDoorOpen = false, IsLightOn = true, IsHeaterOn = true, IsButtonPressed = true, IsTimerOn = true }; var stateChangerToDoorOpen = new StateChangerToDoorOpen(); var stateChangerToInitial = new StateChangerToInitial(); var stateChangerToButtonPressed = new StateChangerToButtonPressed(); stateManager.Register(initialCondition, MicrowaveTrigger.Open, stateChangerToDoorOpen); stateManager.Register(doorOpenCondition, MicrowaveTrigger.Close, stateChangerToInitial); stateManager.Register(initialCondition, MicrowaveTrigger.PressStart, stateChangerToButtonPressed); stateManager.Register(buttonIsPressedCondition, MicrowaveTrigger.PressStart, stateChangerToButtonPressed); stateManager.Register(buttonIsPressedCondition, MicrowaveTrigger.Open, stateChangerToDoorOpen); stateManager.Register(buttonIsPressedCondition, MicrowaveTrigger.Elapsed, stateChangerToInitial); }
protected bool Equals(StateCondition other) { return(IsDoorOpen == other.IsDoorOpen && IsLightOn == other.IsLightOn && IsHeaterOn == other.IsHeaterOn && IsButtonPressed == other.IsButtonPressed && IsTimerOn == other.IsTimerOn); }