Standing: how to determine the initial state substation?

I use stateless to implement state machine logic in our application. We have a state AcceptedFilethat has another internal (sub). The problem is that I don’t know how to specify the initial internal state in my code, so that when the machine AccptedFilegoes into state , it will automatically go back to its original internal state. Here is what I did with simulate this behavior:

 machine.Configure(State.AcceptedFile)
                    .OnEntry(() => machine.Fire(Trigger.MakeReadyForAdvertising))
                    .Permit(Trigger.MakeReadyForAdvertising,State.ReadyForAdvertising)

here ReadyForAdvertisingis an internal state AcceptedFile. This works great in most scenarios, but whenever I set the initial state of my state machine to AcceptedFileas follows:

var statemachine=new StateMachine<State,Trigger>(State.AcceptedFile)
...

An automatic transition will not occur, so the machine will be in the AcceptedFile state instead ReadyForAdvertising.

Is there a better way to implement this behavior?

+4
source share
2 answers

The documentation in StateMachine.cs says:

Substances inherit the permitted transitions of their superpowers. When you enter directly into the stand from outside the superstate, the actions of the entrance for the superstate are performed. Similarly, when you exit a substation into an external superpower, exit actions for the superstate are performed.

, ReadyForAdvertising , ReadyForAdvertising ( )

var statemachine=new StateMachine<State,Trigger>(State.ReadyForAdvertising)

AcceptedFile ReadyForAdvertising ReadyForAdvertising.

+4

. OnExit - , .

0

All Articles