.NET 的状态机框架

3

本文介绍了.NET 的状态机框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的工作中有一个系统,它基本上是一个消息驱动的状态机.它接收各种类型的消息,根据消息查找一些上下文/状态,然后根据消息和当前状态决定要做什么.通常结果是一条消息被发送出系统.

We have a system at my work that is basically a message-driven state machine. It takes in a variety of types of messages, looks up some context/state based on the message, then decides what to do, based on the message and the current state. Normally the result is a message being sent out of the system.

是否有任何好的开源框架可以在 .NET 中实现状态机?我查看了最新版本的 Windows Workflow,它似乎是一个不错的选择;但是,我对默认的持久性机制(我们需要报告状态转换数据)、可测试性以及 WF 团队正在重新构建框架这一事实(据推测)存在一些担忧.

Are there any good open-source frameworks for implementing a state machine in .NET? I've looked into the latest release of Windows Workflow, and it seems like it would be a good option; however, I have some concerns about the default persistence mechanisms (we need to report off the state transition data), testability, and the fact that the WF team is re-architecting the framework as we speak (supposedly).

我正在考虑尝试实现一个普通的 GoF状态"模式,而不是 WF,并使用 Spring.NET 将所有内容连接在一起.有没有什么东西已经这样做了,或者类似的东西?

Instead of WF, I'm thinking of trying to implement a plain-old GoF "State" pattern, and using Spring.NET to wire everything together. Is there anything out there that already does this, or something similar?

推荐答案

根据您的具体要求,您可能会找到 状态机编译器 足以实现 GoF状态"模式.它可以生成 C# 以及可以使用 Graphviz 转换为多种图像格式的点.我在以前的项目中使用过它,发现它足以生成简单"状态机.我希望这有帮助.

Depending on your exact requirements you might find the State Machine Compiler is sufficient for implementing the GoF "State" pattern. It can generate C# as well as dot which can be transformed into several image formats using Graphviz. I've used it on a previous project and found it sufficient for generating a 'simple' state machine. I hope this helps.

这篇关于.NET 的状态机框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14

具有未知类型的 CreateDelegate
CreateDelegate with unknown types(具有未知类型的 CreateDelegate)...
2023-11-11 C#/.NET开发问题
5

Func<T>.BeginInvoke 使用线程池吗?
Does Funclt;Tgt;.BeginInvoke use the ThreadPool?(Funclt;Tgt;.BeginInvoke 使用线程池吗?)...
2023-11-11 C#/.NET开发问题
6

如何为具有空目标的实例方法创建委托?
How to create a delegate to an instance method with a null target?(如何为具有空目标的实例方法创建委托?)...
2023-11-11 C#/.NET开发问题
6