-
-
Notifications
You must be signed in to change notification settings - Fork 14
StateMachine
GMIKE edited this page Jun 20, 2020
·
16 revisions
StateMachine stateMachine = new StateMachine();You can import state machine to xml
StateMachine stateMachine = StateMachine.FromXDocument("fileName.xml");
StateMachine stateMachine = new StateMachine("fileName.xml");You can export state machine to xml
stateMachine.ToXDocument("fileName.xml");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);Triggered after entry to new state.
void ActionOnChangeState(State stateFrom, State stateTo)
{
}stateMachine.OnChangeState(ActionOnChangeState);You can get current state or it name
State currentState = StateMachine.CurrentState;
string currentStateName = StateMachine.CurrentStateName;You can get previus state or it name
State previus State = StateMachine.PreviousState;
string previusStateName = StateMachine.PreviousStateName;You can get current transition or it name
Transition currentTransition= StateMachine.CurrentTransition;
string currentTransitionName= StateMachine.CurrentTransitionName;