FastFsm.Sharp.DependencyInjection 0.9.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FastFsm.Sharp.DependencyInjection --version 0.9.0
                    
NuGet\Install-Package FastFsm.Sharp.DependencyInjection -Version 0.9.0
                    
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="FastFsm.Sharp.DependencyInjection" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastFsm.Sharp.DependencyInjection" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="FastFsm.Sharp.DependencyInjection" />
                    
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 FastFsm.Sharp.DependencyInjection --version 0.9.0
                    
#r "nuget: FastFsm.Sharp.DependencyInjection, 0.9.0"
                    
#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.
#:package FastFsm.Sharp.DependencyInjection@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FastFsm.Sharp.DependencyInjection&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=FastFsm.Sharp.DependencyInjection&version=0.9.0
                    
Install as a Cake Tool

Dependency injection

Install the DI package:

dotnet add package FastFsm.Sharp.DependencyInjection

The package defines FSM_DI_ENABLED and FSM_LOGGING_ENABLED and compiles FsmServiceCollectionExtensions into the consuming project.

Register a state machine

AddStateMachine requires four type parameters: interface, implementation, state enum, and trigger enum.

using FastFsm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

services.AddStateMachine<IOrderWorkflow, OrderWorkflow, OrderState, OrderTrigger>(
    ServiceLifetime.Singleton);

The implementation type is the generated partial state-machine class.

Initial state

By default, the registration uses the first enum value. Configure another initial state with:

services.ConfigureStateMachineInitialState<OrderState>(
    _ => OrderState.Draft);

Register extensions

services.AddStateMachineExtension<AuditExtension>(ServiceLifetime.Singleton);

Extensions registered in DI are supplied to machines generated with extension support. In the current 0.9 codebase, set GenerateExtensibleVersion = true explicitly on those machines; see extensions.md.

Factory

Registration also exposes IStateMachineFactory<TInterface, TState, TTrigger> for explicit creation with a selected initial state.

Defined in src/Fsm/Fsm.Core/DependencyInjection/:

  • FsmServiceCollectionExtensions
  • StateMachineFactory<TInterface, TImplementation, TState, TTrigger>
  • IInitialStateProvider<TState>

Tests

See Tests.DependencyInjection (src/Fsm/Fsm.Tests/Tests.DependencyInjection/) for registration and factory coverage.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FastFsm.Sharp.DependencyInjection:

Package Downloads
FastFsm.Net.DependencyInjection

Legacy package ID. Depends on FastFsm.Sharp.DependencyInjection. New projects should reference FastFsm.Sharp.DependencyInjection directly.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.1 0 8/17/2026
0.9.0 38 8/17/2026

.NET 10 DI package for FastFsm.Sharp. Depends on FastFsm.Sharp. Extension generation remains opt-in. See CHANGELOG.md.