Transito 1.0.0
dotnet add package Transito --version 1.0.0
NuGet\Install-Package Transito -Version 1.0.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="Transito" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Transito" Version="1.0.0" />
<PackageReference Include="Transito" />
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 Transito --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Transito, 1.0.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 Transito@1.0.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=Transito&version=1.0.0
#tool nuget:?package=Transito&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Transito
A generic enum state machine library for .NET that provides attribute-based configuration and fluent builders for managing state transitions.
Features
- Attribute-based Configuration: Define state machines using simple attributes on your enums
- Fluent Builder Pattern: Programmatically configure state machines with a fluent API
- State Categorization: Organize states into categories (Initial, Active, Final, etc.)
- Extension Methods: Easy-to-use extension methods for common state operations
- Thread-safe: Built with concurrent collections for safe multi-threaded usage
- High Performance: Cached state machine instances for optimal performance
Installation
dotnet add package Transito
Quick Start
Attribute-based Configuration
using Transito.Attributes;
[StateMachine(InitialState = OrderStatus.Draft)]
public enum OrderStatus
{
[StateCategory(StateCategory.Initial)]
[AllowTransitionsTo(Submitted, Cancelled)]
Draft,
[StateCategory(StateCategory.Active)]
[AllowTransitionsTo(Processing, Cancelled)]
Submitted,
[StateCategory(StateCategory.Active)]
[AllowTransitionsTo(Shipped, Cancelled)]
Processing,
[StateCategory(StateCategory.Active)]
[AllowTransitionsTo(Delivered)]
Shipped,
[StateCategory(StateCategory.Final)]
Delivered,
[StateCategory(StateCategory.Final)]
Cancelled
}
// Usage
var order = OrderStatus.Draft;
// Check valid transitions
bool canSubmit = order.CanTransitionTo(OrderStatus.Submitted); // true
bool canDeliver = order.CanTransitionTo(OrderStatus.Delivered); // false
// Get all valid transitions
var validTransitions = order.GetValidTransitions(); // [Submitted, Cancelled]
// Check state categories
bool isInitial = order.IsInitialState(); // true
bool isFinal = order.IsFinalState(); // false
Fluent Builder Pattern
using Transito.Builders;
var stateMachine = StateMachineBuilder<OrderStatus>
.Configure()
.Allow(OrderStatus.Draft).To(OrderStatus.Submitted, OrderStatus.Cancelled)
.Allow(OrderStatus.Submitted).To(OrderStatus.Processing, OrderStatus.Cancelled)
.Allow(OrderStatus.Processing).To(OrderStatus.Shipped, OrderStatus.Cancelled)
.Allow(OrderStatus.Shipped).To(OrderStatus.Delivered)
.Allow(OrderStatus.Delivered).ToNone()
.Allow(OrderStatus.Cancelled).ToNone()
.AddStateToCategory(OrderStatus.Draft, StateCategory.Initial)
.AddStateToCategory(OrderStatus.Delivered, StateCategory.Final)
.AddStateToCategory(OrderStatus.Cancelled, StateCategory.Final)
.WithInitialState(OrderStatus.Draft)
.Build();
// Use the state machine
bool canTransition = stateMachine.CanTransitionTo(OrderStatus.Draft, OrderStatus.Submitted);
var initialState = stateMachine.GetInitialState();
Available Attributes
[StateMachine]
- Marks an enum as a state machine[AllowTransitionsTo(...)]
- Defines valid transitions from a state[StateCategory(...)]
- Categorizes states (Initial, Active, Final, Intermediate, Error, Retry)
Extension Methods
CanTransitionTo(newState)
- Check if transition is validGetValidTransitions()
- Get all possible transitionsIsInCategory(category)
- Check if state belongs to categoryIsFinalState()
- Check if state is finalIsInitialState()
- Check if state is initialIsActiveState()
- Check if state is active
State Categories
Initial
- Starting statesActive
- States representing ongoing processesFinal
- Terminal states with no further transitionsIntermediate
- Temporary transition statesError
- Error statesRetry
- States that allow retry operations
License
MIT License - see LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
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.0 | 142 | 7/26/2025 |