.NET的状态机框架 [英] State Machine Frameworks for .NET

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

问题描述

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



在.NET中是否有实现状态机的好的开源框架?我研究了Windows Workflow的最新版本,似乎是一个很好的选择;然而,我有一些关于默认持久性机制(我们需要报告状态转换数据),可测试性以及WF团队在我们说话(据称))重新构架框架的事实。



而不是WF,我正在考虑实现一个简单的GoF状态模式,并使用Spring.NET将所有内容都集中在一起。有没有什么可以做到这一点,还是类似的?

解决方案

根据您的具体要求,您可能会发现状态机编译器足以实现GoF状态模式。它可以生成C#以及点,可以使用 Graphviz 将其转换成多种图像格式。我已经在之前的项目中使用它,发现它足以产生一个简单的状态机。我希望这有帮助。


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.

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).

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?

解决方案

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的状态机框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆