C# 允许用户输入条件规则

发布于 2024-09-26 03:40:52 字数 696 浏览 2 评论 0原文

我独立地编写代码,也就是说,我为自己工作。我需要一些关于如何实现以下功能的建议,或者是否有一些已经存在的工具可以帮助您更轻松地完成此任务。

我有一个场景(C# 应用程序),我希望用户能够输入条件规则,然后在程序的其他地方使用这些规则进行各种计算。

作为一个简单的例子,假设我们有一个 TimeRequiredForJob 属性,我们需要根据用户规则在程序中计算它。一个简单的规则可能是

TimeRequiredForJob = 200 个气球乘以每个气球 5 分钟,或者 TimeRequiredForJob = HoursInAfternoon 的 20%

我猜很难看到我在寻找什么,所以也许下面的图片会有所帮助: DevExpress XtraGrid Filter Example

这是来自 DevExpress XtraGrid,它允许用户根据用户自定义过滤网格中显示的数据过滤规则。我想实现类似的东西,但能够将规则保存到数据库并稍后在应用程序中使用这些规则。

欢迎任何建议或提示。

[后期编辑]

实际上,我从这个问题中获得了一些很好的信息,但还有任何其他信息将不胜感激。

I write code in isolation, that is I work for myself. I need some advice on how you might implement the following functionality or if there are some tools that already exist to help make this task easier to accomplish.

I have a scenario (C# application) in which I would like the user to be able to enter conditional rules which will then be used elsewhere in the program for various calculations.

As a simple example let's say we have a TimeRequiredForJob property and we need to calculate this in the program based upon the users rules. A simple rule might be

TimeRequiredForJob = 200 Balloons multiplied by 5 min each, or
TimeRequiredForJob = 20% of HoursInAfternoon

I am guessing its pretty hard to see what I am looking for so maybe the following image will help:
DevExpress XtraGrid Filter Example

This is from DevExpress XtraGrid and it allows a user to filter data displayed in the grid based upon the users custom filter rules. I would like to implement something similar but be able to save the rules to a database and use those rules later in the application.

Any suggestions or tips welcome.

[Late Edit]

Actually I am getting some good information from this question but any additional information will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

定格我的天空 2024-10-03 03:40:52

暂时忘记 GUI,您首先需要构建某种规则评估处理器。

您可能会发现这篇关于构建评估引擎的文章很有帮助。它描述将文本表达式处理为可以计算的形式。

一旦您找到了表示这些规则的方法(无论是作为对象结构还是作为文本表达式),构建 GUI 以满足您的特定要求的任务就会变得更加容易。

Forgetting about the GUI for a second, you will need to first need to build some kind of rule evaluation processor.

You may find this article on building an Evaluation Engine helpful. It describes processing text expressions into a form that can be evaluated.

Once you have a way of representing these rules (either as an object structure or as text expressions) the task of building a GUI to suit your specific requirements will become easier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文