FastFsm.Net.DependencyInjection
0.9.0
See the version list below for details.
dotnet add package FastFsm.Net.DependencyInjection --version 0.9.0
NuGet\Install-Package FastFsm.Net.DependencyInjection -Version 0.9.0
<PackageReference Include="FastFsm.Net.DependencyInjection" Version="0.9.0" />
<PackageVersion Include="FastFsm.Net.DependencyInjection" Version="0.9.0" />
<PackageReference Include="FastFsm.Net.DependencyInjection" />
paket add FastFsm.Net.DependencyInjection --version 0.9.0
#r "nuget: FastFsm.Net.DependencyInjection, 0.9.0"
#:package FastFsm.Net.DependencyInjection@0.9.0
#addin nuget:?package=FastFsm.Net.DependencyInjection&version=0.9.0
#tool nuget:?package=FastFsm.Net.DependencyInjection&version=0.9.0
Dependency injection
Install the DI package:
dotnet add package FastFsm.Net.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.
Related types
Defined in FastFsm/DependencyInjection/:
FsmServiceCollectionExtensionsStateMachineFactory<TInterface, TImplementation, TState, TTrigger>IInitialStateProvider<TState>
Tests
See FastFsm.DependencyInjection.Tests for registration and factory coverage.
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- FastFsm.Net (>= 0.9.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
.NET 10 DI package for FastFsm.Net. Depends on FastFsm.Net. Extension generation remains opt-in. See CHANGELOG.md.