Class StateMachineInstanceExtensions
- Namespace
- LfrlAnvil.Computable.Automata.Extensions
- Assembly
- LfrlAnvil.Computable.Automata.dll
Contains IStateMachineInstance<TState, TInput, TResult> extension methods.
public static class StateMachineInstanceExtensions
- Inheritance
-
StateMachineInstanceExtensions
- Inherited Members
Methods
CanAccept<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>)
Checks whether or not the instance
can transition to an accepted state.
[Pure]
public static bool CanAccept<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- bool
true when
instance
can transition to an accepted state, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
CanTransitionTo<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, TState)
Checks whether or not the instance
can transition to the provided destination
state.
[Pure]
public static bool CanTransitionTo<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, TState destination) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
destination
TStateDestination state to check.
Returns
- bool
true when
instance
can transition to thedestination
state, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
CanTransition<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>)
Checks whether or not the instance
can transition to any other state.
[Pure]
public static bool CanTransition<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- bool
true when
instance
can transition to any other state, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
CanTransition<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, TInput)
Checks whether or not the instance
can transition with the provided transition identifier.
[Pure]
public static bool CanTransition<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, TInput input) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
input
TInputTransition identifier.
Returns
- bool
true when
instance
can transition with the provided transition identifier, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
Clone<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>)
Creates a clone of the provided state machine instance
.
[Pure]
public static IStateMachineInstance<TState, TInput, TResult> Clone<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance equivalent to the provided
instance
.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
Clone<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, object)
Creates a clone of the provided state machine instance
.
[Pure]
public static IStateMachineInstance<TState, TInput, TResult> Clone<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, object subject) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
subject
objectCustom subject.
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance equivalent to the provided
instance
.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
Clone<TState, TInput, TResult>(StateMachineInstance<TState, TInput, TResult>)
Creates a clone of the provided state machine instance
.
[Pure]
public static StateMachineInstance<TState, TInput, TResult> Clone<TState, TInput, TResult>(this StateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
StateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- StateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance equivalent to the provided
instance
.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
Clone<TState, TInput, TResult>(StateMachineInstance<TState, TInput, TResult>, object)
Creates a clone of the provided state machine instance
.
[Pure]
public static StateMachineInstance<TState, TInput, TResult> Clone<TState, TInput, TResult>(this StateMachineInstance<TState, TInput, TResult> instance, object subject) where TState : notnull where TInput : notnull
Parameters
instance
StateMachineInstance<TState, TInput, TResult>Source state machine instance.
subject
objectCustom subject.
Returns
- StateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance equivalent to the provided
instance
.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
FindTransitionsTo<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, TState)
Creates a new IEnumerable<T> instance that contains all currently available transitions
to destination
state.
[Pure]
public static IEnumerable<KeyValuePair<TInput, IStateMachineTransition<TState, TInput, TResult>>> FindTransitionsTo<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, TState destination) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
destination
TStateDestination state.
Returns
- IEnumerable<KeyValuePair<TInput, IStateMachineTransition<TState, TInput, TResult>>>
New IEnumerable<T> instance.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
GetAvailableDestinations<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>)
Creates a new IEnumerable<T> instance that contains all currently available destination states.
[Pure]
public static IEnumerable<IStateMachineNode<TState, TInput, TResult>> GetAvailableDestinations<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- IEnumerable<IStateMachineNode<TState, TInput, TResult>>
New IEnumerable<T> instance.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
GetTransition<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, TInput)
Returns an IStateMachineTransition<TState, TInput, TResult> instance for the current state and transition identifier.
[Pure]
public static IStateMachineTransition<TState, TInput, TResult> GetTransition<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, TInput input) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
input
TInputTransition identifier.
Returns
- IStateMachineTransition<TState, TInput, TResult>
IStateMachineTransition<TState, TInput, TResult> instance associated with the current state and transition identifier.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
Exceptions
- StateMachineTransitionException
When transition does not exist in the current state.
IsAccepted<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>)
Checks whether or not the instance
is in accepted state.
[Pure]
public static bool IsAccepted<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
Returns
- bool
true when
instance
is in accepted state, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
TryGetTransition<TState, TInput, TResult>(IStateMachineInstance<TState, TInput, TResult>, TInput, out IStateMachineTransition<TState, TInput, TResult>)
Attempts to return an IStateMachineTransition<TState, TInput, TResult> instance for the current state and transition identifier.
public static bool TryGetTransition<TState, TInput, TResult>(this IStateMachineInstance<TState, TInput, TResult> instance, TInput input, out IStateMachineTransition<TState, TInput, TResult> result) where TState : notnull where TInput : notnull
Parameters
instance
IStateMachineInstance<TState, TInput, TResult>Source state machine instance.
input
TInputTransition identifier.
result
IStateMachineTransition<TState, TInput, TResult>out parameter that returns an IStateMachineTransition<TState, TInput, TResult> instance associated with the current state and transition identifier.
Returns
- bool
true when transition exists, otherwise false.
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.