I am using stateless to implement logic of a state machine in our application.We have an AcceptedFile
state that has other inner (sub)states.The problem is I don't know how should I indicate initial inner state in my code so that when a machine transit to AccptedFile
state it would also automatically transit to its initial inner state.Here's what I did to simulate this behavior :
machine.Configure(State.AcceptedFile)
.OnEntry(() => machine.Fire(Trigger.MakeReadyForAdvertising))
.Permit(Trigger.MakeReadyForAdvertising,State.ReadyForAdvertising)
here ReadyForAdvertising
is an inner state of AcceptedFile
.This works fine in most of the scenarios but whenever I set the initial state of my state machine to AcceptedFile
like this :
var statemachine=new StateMachine<State,Trigger>(State.AcceptedFile)
...
The automatic transition would not happen thus machine will be in AcceptedFile state instead of ReadyForAdvertising
.
Is there a better way to implement this behavior ?