Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

StateMachine

GMIKE edited this page Jun 20, 2020 · 16 revisions

Сontent

Create

StateMachine stateMachine = new StateMachine();

Import

You can import state machine to xml

StateMachine stateMachine = StateMachine.FromXDocument("fileName.xml");
StateMachine stateMachine = new StateMachine("fileName.xml");

Export

You can export state machine to xml

stateMachine.ToXDocument("fileName.xml");

Logging

For logging you need use ILogger

//Example create logger
var loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole().AddDebug().SetMinimumLevel(LogLevel.Debug); });
var logger = loggerFactory.CreateLogger<StateMachine>();
StateMachine stateMachine = new StateMachine(logger);
StateMachine stateMachine = StateMachine.FromXDocument("fileName.xml", logger);
StateMachine stateMachine = new StateMachine("fileName.xml", logger);

OnChangeState

Triggered after entry to new state.

Action Syntax

 void ActionOnChangeState(State stateFrom, State stateTo)
 {
 }

Add action

stateMachine.OnChangeState(ActionOnChangeState);

CurrentState

You can get current state or it name

State currentState = StateMachine.CurrentState;
string currentStateName = StateMachine.CurrentStateName;

PreviousState

You can get previus state or it name

State previus State = StateMachine.PreviousState;
string previusStateName = StateMachine.PreviousStateName;

CurrentTransition

You can get current transition or it name

Transition currentTransition= StateMachine.CurrentTransition;
string currentTransitionName= StateMachine.CurrentTransitionName;

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /