Skip to content

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy