记录C#表达树调用

发布于 2025-01-24 18:43:05 字数 625 浏览 2 评论 0原文

我希望使用从此处给出的示例开始使用表达式树创建一个简单的规则引擎: https://mobiusstraits.com/2015/08/12/expression-trees/

我想知道我如何记录每个规则的评估规则引擎。

理想情况下,我想拥有一个字符串列表,其中包含在给定模型上评估的每个规则的评估结果列表,例如。

“ field1传递值x匹配规则x” “ field2失败值x不匹配规则值y”

沿这些行。这将使StringList返回到调用规则引擎的任何功能。

我在这里遇到了这个答案: https://stackoverflow.com/a/34042462/1270329在表达类中没有解释()方法,所以很明显我错过了有关该解决方案的一些东西。

有人可以把我朝正确的方向设置吗?我应该提到我刚刚了解了这些表达树。

tia

I am looking to create a simple rules engine using expression trees starting from the example given here: https://mobiusstraits.com/2015/08/12/expression-trees/

I'm wondering how I might log the evaluation of each of the rules to that I can create a log of why the model failed the rules engine.

Ideally, I would like to have a stringlist containing a list of evaluation results for each of the rules evaluated on a given model, eg.

"Field1 passed value X matched rule X"
"Field2 failed value X did not match rule value Y"

something along those lines. This would enable to return the stringlist back to whatever function invoked the rules engine.

I came across this answer here: https://stackoverflow.com/a/34042462/1270329, which looked promising but there is no Interpret() method on an Expression class so clearly I've missed something about that solution.

Can someone set me in the right direction. I should mention I just learned of these expression trees.

TIA

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文