规则引擎设计与C# 中的示例
我目前正在使用 C# 编写一个 .net 应用程序,想要检查一些规则,并根据通过或失败的规则来执行操作。因此,我希望实现一个通用的解决方案,我可以重复使用该解决方案,并遵循良好的 oop 原则。这使我得出的结论是我需要编写一个规则引擎。
我对 C# 有很好的了解,但这是我第一次需要编写规则引擎,因此作为我设计和开发此类引擎的研究的一部分,我正在寻找有关创建此类引擎的任何提示。如果有什么我可以看的例子就更棒了?有任何 c#/.net 规则引擎应用程序吗?典型的三层架构中的哪一层应该是这样的?我快速浏览了 codeplex 和谷歌代码,但没有一个让我眼前一亮!所以一些方向会很棒。
I am currently writing a .net application with c# and want to check a number of rules and based on passing or failing the rules, perform an action. So I am looking to implement a generic solution that I can reuse adhering to good oop principles. This has lead me to the conclusion that I need to write a rules engine.
I have good knowledge of c# but this is the first time I have needed to write a rules engine so as part of my research in to the design and development of such, I am looking for any tips regarding the creation of such an engine. What would be great further would be any examples out there that I could look at? Any c#/.net rules engine applications? What layer in a typical 3 tier architecture should such reside at? I had a quick look on the codeplex and google code but none jumped out at me! So some direction would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,.NET 有一个顶级的规则引擎,旨在与工作流一起使用(正如它的设计目的),但也可以轻松地在工作流之外使用:您应该看到“Windows Workflow Foundation 规则引擎" 并检查 System.Workflow.Activities.Rules 命名空间。
学习如何在工作流程之外使用规则只需要一点谷歌搜索。
编辑:如果您想检查架构,这里有两个开源预构建引擎:
Actually .NET has a top-notch rules engine meant to be used with workflows (as it is designed to be) but can be used outside of workflows easily: You should see "Windows Workflow Foundation Rules Engine" and inspect the System.Workflow.Activities.Rules namespace.
Learning how to use rules outside of workflows takes only a bit of googling.
Edit: If you want to inspect the architecture, here is two open-source prebuilt engines:
构建和实现您自己的规则引擎可能是一项非常困难的任务,需要考虑很多事情。您将面临的最大问题是尝试决定何时触发哪些规则。如果不给予适当的关注,可能会导致实施过程中出现性能问题。我强烈建议您专注于业务问题,并为您的主题专家 (SME) 提供定义和维护自己的规则的能力。有许多优秀的商业产品可以做到这一点;我已经成功实施多次的是www.inrule.com。他们有一套很好的产品,可以帮助解决简单和复杂的问题。希望这有帮助。
Building and implementing your own rules engine can be a very difficult task with many things to consider. The biggest problem you will face is trying to decide which rules to fire and when. Not giving this the proper care can lead to performance problems within the implementation. I would highly recommend focusing in on the business problem and providing your subject matter experts (SME’s) with the ability to define and maintain their own rules. There are many good commercial products that do this; the one I have successfully implemented multiple times is www.inrule.com. They have a nice set of products that can help solve simple and complex problems. Hopefully this helps.