Table of Contents

Class StateMachineInstance<TState, TInput, TResult>

Namespace
LfrlAnvil.Computable.Automata
Assembly
LfrlAnvil.Computable.Automata.dll

Represents an instance of a deterministic finite state machine.

public sealed class StateMachineInstance<TState, TInput, TResult> : IStateMachineInstance<TState, TInput, TResult> where TState : notnull where TInput : notnull

Type Parameters

TState

State type.

TInput

Input type.

TResult

Resul type.

Inheritance
StateMachineInstance<TState, TInput, TResult>
Implements
IStateMachineInstance<TState, TInput, TResult>
Inherited Members
Extension Methods

Properties

CurrentState

State in which this instance currently is.

public IStateMachineNode<TState, TInput, TResult> CurrentState { get; }

Property Value

IStateMachineNode<TState, TInput, TResult>

Machine

Source state machine.

public StateMachine<TState, TInput, TResult> Machine { get; }

Property Value

StateMachine<TState, TInput, TResult>

Subject

Subject of this instance. Equal to this unless this instance has been created with a custom subject.

public object Subject { get; }

Property Value

object

Methods

Transition(TInput)

Transitions this instance to the provided state.

public TResult Transition(TInput input)

Parameters

input TInput

Transition identifier.

Returns

TResult

Result returned by the transition.

Exceptions

StateMachineTransitionException

When CurrentState cannot transition with the provided input.

TryTransition(TInput, out TResult)

Attempts to transition this instance to the provided state.

public bool TryTransition(TInput input, out TResult result)

Parameters

input TInput

Transition identifier.

result TResult

out parameter that returns the result returned by the transition.

Returns

bool

true when transition was successful, otherwise false.