登录 注册
其他
6,288
Stars
804
Forks
227
Watchers
79
Open Issues
NOASSERTION
许可证
C#
语言
2014-08-15
创建时间
2026-11-08
最近更新

项目能做什么

用于在 C# 代码中创建状态机的轻量级库。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Stateless [![Build status](https://github.com/dotnet-state-machine/stateless/actions/workflows/BuildAndTestOnPullRequests.yml/badge.svg)](https://github.com/dotnet-state-machine/stateless/actions/workflows/BuildAndTestOnPullRequests.yml) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Stateless.svg)](https://www.nuget.org/packages/stateless) [![Join the chat at https://gitter.im/dotnet-state-machine/stateless](https://badges.gitter.im/dotnet-state-machine/stateless.svg)](https://gitter.im/dotnet-state-machine/stateless?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Stack Overflow](https://img.shields.io/badge/stackoverflow-tag-orange.svg)](http://stackoverflow.com/questions/tagged/stateless-state-machine)

**Create *state machines* and lightweight *state machine-based workflows* directly in .NET code:**

```csharp
var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialled, State.Ringing);

phoneCall.Configure(State.Connected)
    .OnEntry(t => StartCallTimer())
    .OnExit(t => StopCallTimer())
    .InternalTransition(Trigger.MuteMicrophone, t => OnMute())
    .InternalTransition(Trigger.UnmuteMicrophone, t => OnUnmute())
    .InternalTransition<int>(_setVolumeTrigger, (volume, t) => OnSetVolume(volume))
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);
```

This project, as well as the example above, was inspired by [Simple State Machine (Archived)](https://web.archive.org/web/20170814020207/http://simplestatemachine.codeplex.com/).

## Features

Most standard state machine constructs are supported:

 * Generic support for states and triggers of any .NET type (numbers, strings, enums, etc.)
 * Hierarchical states
 * Entry/exit actions for states
 * Guard clauses to support conditional transitions
 * Introspection

Some useful extensions are also provided:

 * Ability to store state externally (for example, in a property tracked by an ORM)
 * Parameterised triggers
 * Reentrant states
 * Export to DOT graph
 * Export to mermaid graph

### Hierarchical States


In the example below, the `OnHold` state is a substate of the `Connected` state. This means that an `OnHold` call is still connected.

```csharp
phoneCall.Configure(State.OnHold)
    .SubstateOf(State.Connected)
    .Permit(Trigger.TakenOffHold, State.Connected)
    .Permit(Trigger.PhoneHurledAgainstWall, State.PhoneDestroyed);
```

In addition to the `StateMachine.State` property, which will report the precise current state, an `IsInState(State)` method is provided. `IsInState(State)` will take substates into account, so that if the example above was in the `OnHold` state, `IsInState(State.Connected)` would also evaluate to `true`.

### Entry/Exit actions

In the example, the `StartCallTimer()` method will be executed when a call is conn
阅读完整原文

项目深度分析 AI 生成

Stateless 视觉化设计器与代码生成器 (VS Code/Visual Studio 插件 + Web)

产品构想利用 Stateless 已有的 DOT/Mermaid 导出能力,逆向提供双向可视化设计器:通过拖拽绘制状态机图,自动生成标准的 Stateless C# 配置代码,或从现有 C# 代码反向同步图表。
核心功能拖拽式状态/触发器设计、分层状态支持、守卫条件可视化配置、直接生成/同步 Stateless Fluent API C# 代码、Mermaid/DOT双向导入导出
目标用户C# 软件架构师、业务逻辑开发者、敏捷开发团队
难度/周期中等 · 1-2个月 · 成本:开发机器、IDE插件开发者账号(微软商城年费极低)
收费模式免费基础功能,专业版(高级代码模板、实时双向代码同步、团队导出规范)按席位订阅制收费
竞争风险目标开发者更倾向于纯代码编写,对图形化配置的刚需程度可能低于预期
依据 已验证事实

基于 Stateless 的分布式持久化工作流服务 (Stateless Cloud/Server)

产品构想针对 Stateless 原生仅支持内存运行的特点,包装一套支持持久化(EF Core/Dapr/Redis)、定时触发、重试补偿、分布式锁开箱即用的轻量级业务编排引擎服务。
核心功能状态机实例持久化中间件、定时器/延迟触发器、分布式并发控制、事件回放与追踪看板、开箱即用的 ASP.NET Core 集成包
目标用户.NET 微服务架构师、电商/订单/审批流业务开发团队
难度/周期较高 · 2-3个月 · 成本:云服务器测试环境、数据库实例成本
收费模式核心开源,高级功能(企业级集群、运维Dashboard UI、商业持久化适配器)提供商业授权或托管 SaaS 订阅
竞争风险面临 Temporal、MassTransit、Workflow Core 等成熟分布式编排框架的激烈竞争
依据 AI推测

状态机合规审计与可观测性套件 (Stateless Inspector)

产品构想为企业级 Stateless 应用提供运行期状态追踪、性能分析、非法状态转换告警和审计日志归档组件。
核心功能零侵入的 AOP/中间件遥测采集、OpenTelemetry 原生接入、状态流转时间序列看板、死锁/孤岛状态死循环检测、合规审计追踪导出
目标用户金融科技、医疗健康、物联网等对状态流转审计合规要求严格的企业系统开发者
难度/周期中等 · 1-2个月 · 成本:本地开发及云端监控展示轻量环境
收费模式商业授权(按节点/应用收费),提供定制审计报表服务
竞争风险由于纯库无中心化节点,遥测集成可能需要侵入现有业务代码,推广阻力较大
依据 尚需验证的假设
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建于 2014-08-15,近 30 天仍在推送
社区活跃Star 6,288 / Fork 804 / Issue 79(数据支持,可自行核实)
许可证NOASSERTION
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。