Class StateProfile
This class tracks the state or set of states the system could be in, as well as active step functions that can further impact that state.
The most frequent use case is the system being in a single state, and each operation optionally transitioning it to a single next state.
There are situations however where the system can be in one of a possible set of states. As an example, consider a web service endpoint that returns a timeout error. A timeout error might not always mean the operation did not finish. Maybe it didn't, or maybe it did but the server's timeout stopwatch expired before it could return a successful response. So the system can be in one of two states: one in which the operation never happened and the other in which it did happen. This class can allow us to represent both the possibilities. In such situations, further operations (say a GET call on the web service endpoint) can help resolve the ambiguity the system is in.
Finally, certain operations can trigger active processes within the system that can transition the system to possible next states without the user taking any explicit action. As an example, consider a web service endpoint that starts a long running background process that can transition the system through a sequence of states. This class can represent such processes by associating a set of step functions associated with each possible state the system can be in.
public class StateProfile
- Inheritance
-
StateProfile
- Inherited Members
Constructors
StateProfile(IState)
Constructs an instance of this class given a single state.
public StateProfile(IState state)
Parameters
stateIState
StateProfile(IList<IState>)
Constructs an instance of this class given a set of states.
public StateProfile(IList<IState> states)
Parameters
StateProfile(IList<(IState, IList<IStepFunction>)>)
Constructs an instance of this class given a set of states and associated step functions.
public StateProfile(IList<(IState, IList<IStepFunction>)> statesAndStepFunctions)
Parameters
statesAndStepFunctionsIList<(IState State, IList<IStepFunction> StepFunctions)>
Properties
StatesAndStepFunctions
The set of states the system can be and the set of step functions associated with each of those states.
public IList<(IState State, IList<IStepFunction> StepFunctions)> StatesAndStepFunctions { get; set; }
Property Value
Methods
IsSingleState()
This method indicates if a system is uniquely in a single state or if it could be in more than one possible state.
public bool IsSingleState()
Returns
SingleState()
This method returns the single next state but only if the set of next states contains a single state. It throws the MultipleStateException exception otherwise.
public IState SingleState()
Returns
ToString()
public override string ToString()