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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BeatyBit.Binstate" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BeatyBit.Binstate" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="BeatyBit.Binstate" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BeatyBit.Binstate --version 1.0.1
                    
#r "nuget: BeatyBit.Binstate, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=BeatyBit.Binstate&version=1.0.1
                    
Install BeatyBit.Binstate as a Cake Addin
#tool nuget:?package=BeatyBit.Binstate&version=1.0.1
                    
Install BeatyBit.Binstate as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 73 3/29/2025
1.0.0 140 3/16/2025

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.