/// <summary> /// Processes the finite state machine with the given <see cref="Trigger"/>. /// </summary> /// <param name="trigger">The trigger.</param> /// <exception cref="ArgumentNullException">Throws if the trigger is null.</exception> internal void Process(Trigger trigger) { var transition = new StateTransition <T>(this.State, trigger); if (this.stateTransitionTable.TryGetValue(transition, out var state)) { this.State = state; } else { throw new InvalidOperationException($"Invalid state transition ({transition.Description()})."); } }
/// <summary> /// Returns a value indicating whether this instance is equal to the specified <see cref="StateTransition{T}"/>. /// </summary> /// <param name="other">The other state transition.</param> /// <returns>A boolean.</returns> public bool Equals(StateTransition <T> other) => this.CurrentState.Equals(other.CurrentState) && this.Trigger.Equals(other.Trigger);