Professional Documents
Culture Documents
if (entry.ToString() == code)
Unlocked {
state = State.Unlocked;
break;
} }
if (!code.StartsWith(entry.ToString()))
{
// the code is blatantly wrong
state = State.Failed;
}
break;
case State.Failed:
Console.CursorLeft = 0;
Console.WriteLine("FAILED");
entry.Clear();
state = State.Locked;
break;
case State.Unlocked:
Console.CursorLeft = 0;
Console.WriteLine("UNLOCKED");
return;
}
}
C# Switch Expressions
enum Chest { Open, Closed, Locked }
enum Action { Open, Close }
https://github.com/dotnet-state-machine/stateless
phoneCall.Configure(State.OffHook)
.Permit(Trigger.CallDialled, State.Ringing);
State Machines with Stateless (continued)
phoneCall.Configure(State.Connected)
.Permit(Trigger.LeftMessage, State.OffHook)
.Permit(Trigger.PlacedOnHold, State.OnHold);
Stateless feature
● Entry / Exit actions
● Guard clauses
● Parameterized Triggers
● Reentrant