BeatyBit.Binstate
1.0.1
Requires NuGet 2.8 or higher.
dotnet add package BeatyBit.Binstate --version 1.0.1
NuGet\Install-Package BeatyBit.Binstate -Version 1.0.1
<PackageReference Include="BeatyBit.Binstate" Version="1.0.1" />
<PackageVersion Include="BeatyBit.Binstate" Version="1.0.1" />
<PackageReference Include="BeatyBit.Binstate" />
paket add BeatyBit.Binstate --version 1.0.1
#r "nuget: BeatyBit.Binstate, 1.0.1"
#addin nuget:?package=BeatyBit.Binstate&version=1.0.1
#tool nuget:?package=BeatyBit.Binstate&version=1.0.1
Binstate
Binstate is a simple but yet powerful thread-safe, hierarchical state machine for .NET. Features include support for async methods, argument passing, state serialization, and more.
See documentation for full details
https://github.com/Ed-Pavlov/Binstate#readme
Features
Thread safety
The state machine is fully thread safe and allows calling any method from any thread.
Control on what thread enter and exit actions are executed
Binstate doesn't use its own thread to execute actions. It gives an application full control over the threading model of the state machine, and only you decide will it be a passive or an active state machine.
Support async methods
.OnEnter( new Func<Task<string>>( async () => { var result = await HttGetRequest(); return GetOpponentName(result); } )
Hierarchically nested states
builder .DefineState(States.OnFloor) .AsSubstateOf(States.Healthy) // set parent state .OnEnter(AnnounceFloor)
Conditional transitions using C# not DSL
.AddTransition(CallDialed, () => IsValidNumber ? Ringing : Beeping) .AddTransition(GoUp, () => { if(CheckOverload) return MovingUp; AnnounceOverload(); return null; // no transition will be executed });
Enter/Exit/OnTransition actions with arguments
builder .DefineState(WaitingForGame) .OnExit<string>(WaitForGame) .AddTransition<string>(GameStarted, TrackingGame, OnTransitionToTrackingGame) ... builder .DefineState(TrackingGame) .OnEnter<string>(TrackGame) ...
Persistence
Serialize the state machine's current state using var serializedData = stateMachine.Serialize()
.<br>
To restore it later, use var stateMachine = builder.Restore(serializedData)
.<br>
This recreates the state machine in its saved state, ready to resume operation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- BeatyBit.Bits (>= 0.0.20)
- System.Text.Json (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added persistence support:
- Implemented serialization and deserialization for the state machine.
- Added interface `ICustomSerializer` for implementing custom persistence logic.
- Implemented `EnumSerializer` for handling enum persistence as an example of `ICustorSerializer` implementation.