C#规则带有带有自定义规则的表达树的引擎
我希望使用从此处给出的示例开始使用表达式树创建一个简单的规则引擎: https://www.psclistens.com/insight/blog/blog/quickly-build-build-a-build-a-business-engine-engine-engine-engine-angine-using-c- using-c-- and-lambda-expression-Trees/
在示例中,作者使用以下代码构造规则:
// Create some rules using LINQ.ExpressionTypes for the comparison operators
new Rule ( "Year", ExpressionType.GreaterThan, "2012"),
new Rule ( "Make", ExpressionType.Equal, "El Diablo"),
new Rule ( "Model", ExpressionType.Equal, "Torch" )
所使用的表达式是简单的比较操作。如何使用此示例可以按照以下方式创建一个规则:
- 新规则(“模型”,scressionType.isin,{“ ab”,“ ac”,“ ad”,“ ad”})
- 新规则(“模型”,scressiveType。包含“包含值”)
- 新规则{“ model”,cressiveType.istrue,somefuncthatreturnsbool(param))
是否可以给出以上的任何一个给定的示例?
tia
I am looking to create a simple rules engine using expression trees starting from the example given here: https://www.psclistens.com/insight/blog/quickly-build-a-business-rules-engine-using-c-and-lambda-expression-trees/
In the example, the author constructs rules using the following code:
// Create some rules using LINQ.ExpressionTypes for the comparison operators
new Rule ( "Year", ExpressionType.GreaterThan, "2012"),
new Rule ( "Make", ExpressionType.Equal, "El Diablo"),
new Rule ( "Model", ExpressionType.Equal, "Torch" )
The Expressions used are simple comparison ops. How might one, using this sample, create a rule along the lines of:
- new Rule ( "Model", ExpressionType.IsIn, {"AB", "AC", "AD"} )
- new Rule ( "Model", ExpressionType.Contains, "ContainedValue")
- new Rule { "Model", ExpressionType.IsTrue, SomeFuncThatReturnsBool(Param))
Are any of the above possible given the example cited?
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论