Galosoft.IaaS.Stateless 24.12.4.2-nj

This is a prerelease version of Galosoft.IaaS.Stateless.
dotnet add package Galosoft.IaaS.Stateless --version 24.12.4.2-nj                
NuGet\Install-Package Galosoft.IaaS.Stateless -Version 24.12.4.2-nj                
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="Galosoft.IaaS.Stateless" Version="24.12.4.2-nj" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Galosoft.IaaS.Stateless --version 24.12.4.2-nj                
#r "nuget: Galosoft.IaaS.Stateless, 24.12.4.2-nj"                
#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.
// Install Galosoft.IaaS.Stateless as a Cake Addin
#addin nuget:?package=Galosoft.IaaS.Stateless&version=24.12.4.2-nj&prerelease

// Install Galosoft.IaaS.Stateless as a Cake Tool
#tool nuget:?package=Galosoft.IaaS.Stateless&version=24.12.4.2-nj&prerelease                

DI

Galosoft.IaaS.Stateless

      services.AddStateless();

Definition

public class OrderStateMachine : Stateless<OrderState, OrderStateTrigger>
    {
        protected override void Configure(StateMachine<OrderState, OrderStateTrigger> sm)
        {
            sm.Configure(OrderState.Created)
                .Permit(OrderStateTrigger.Pay, OrderState.Paid)
                .Permit(OrderStateTrigger.Close, OrderState.Closed);

            sm.Configure(OrderState.Paid)
               .Permit(OrderStateTrigger.Deliver, OrderState.Delivered)
               .Permit(OrderStateTrigger.Refund, OrderState.Refunded);

            sm.Configure(OrderState.Delivered)
               .Permit(OrderStateTrigger.Return, OrderState.Returned);
        }
    }

    public enum OrderStateTrigger
    {
        Pay,
        Deliver,
        Confirm,
        Close,
        Refund,
        Return
    }

    public enum OrderState
    {
        Created,
        Paid,
        Delivered,
        Confirmed,
        Closed,
        Refunded,
        Returned
    }

QucikStart

  using (var scope = _scopeFactory.CreateScope())
            {
                var sp = scope.ServiceProvider;
                var orderSm = sp.GetRequiredService<OrderStateMachine>();

                orderSm.Init(OrderState.Created);
                await orderSm.FireAsync(OrderStateTrigger.Close);
                await orderSm.FireAsync(OrderStateTrigger.Pay);
                await orderSm.FireAsync(OrderStateTrigger.Deliver);
                await orderSm.FireAsync(OrderStateTrigger.Confirm);
                await orderSm.FireAsync(OrderStateTrigger.Pay);
            }
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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
24.12.4.2-nj 51 12/4/2024
24.12.4.1-nj 48 12/4/2024
24.12.4-nj 46 12/4/2024