Class ReprocessRequestStateManager
- Namespace
- Geotab.Checkmate.ObjectModel.Reprocessing
- Assembly
- Geotab.Checkmate.ObjectModel.dll
A lightweight state machine used by ReprocessRequest and DeviceReprocessRequest.
public class ReprocessRequestStateManager
- Inheritance
-
ReprocessRequestStateManager
- Inherited Members
Constructors
ReprocessRequestStateManager(List<(ReprocessRequestStatus From, ReprocessRequestStatus To)>)
Initializes a new instance of the ReprocessRequestStateManager class.
public ReprocessRequestStateManager(List<(ReprocessRequestStatus From, ReprocessRequestStatus To)> validStateTransitions)
Parameters
validStateTransitions
List<(ReprocessRequestStatus From, ReprocessRequestStatus To)>The list of valid state transitions for this state machine.
Methods
IsTerminalState(ReprocessRequestStatus)
Check whether a state is terminal. A state is considered terminal if there are no valid transitions out of that state.
public bool IsTerminalState(ReprocessRequestStatus status)
Parameters
status
ReprocessRequestStatusThe status to check.
Returns
- bool
Returns
true if thestatus
is in a terminal state, otherwisefalse
IsValidStateTransition(ReprocessRequestStatus, ReprocessRequestStatus)
Check whether a state transition is valid.
public bool IsValidStateTransition(ReprocessRequestStatus oldStatus, ReprocessRequestStatus newStatus)
Parameters
oldStatus
ReprocessRequestStatusThe existing status.
newStatus
ReprocessRequestStatusThe status to transition to.
Returns
- bool
true if the state can be transitioned fromoldStatus
tonewStatus
, otherwisefalse .
ThrowIfInvalidStateTransition(ReprocessRequestStatus?, ReprocessRequestStatus)
Check if a state transition is valid, and throw an exception if not.
public void ThrowIfInvalidStateTransition(ReprocessRequestStatus? oldStatus, ReprocessRequestStatus newStatus)
Parameters
oldStatus
ReprocessRequestStatus?The original status.
newStatus
ReprocessRequestStatusThe status to transition to.
Exceptions
- Exception
Throws an exception if the state transition is invalid.