GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — StateMachine

StateMachine

Jump to bottom
GMIKE edited this page Jun 20, 2020 · 16 revisions

Сontent

  • Create
  • Import
  • Export
  • Logging
  • OnChangeState
  • CurrentState
  • PreviousState
  • CurrentTransition

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;

Documentation

  • StateMachine
  • State
  • Transition
  • Data

Clone this wiki locally

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.