C# 如何通过规则编辑器设置动态消息?

C# 如何通过规则编辑器设置动态消息?,c#,rule-engine,business-rules,codeeffects,C#,Rule Engine,Business Rules,Codeeffects,我需要根据规则编辑器中的参数字段值设置动态消息。 例如 如果AC,则将消息设置为值应在C和D之间更新: 有这样一个源对象: public class Source { private const string template1 = "Age must be between {0} and {1}"; private const string template2 = "Student Age could be greater than {0}"

我需要根据规则编辑器中的参数字段值设置动态消息。 例如
如果AC,则将消息设置为值应在C和D之间

更新:

有这样一个源对象:

public class Source
{
   private const string template1 = "Age must be between {0} and {1}";
   private const string template2 = "Student Age could be greater than {0}";

   public int A, B, C;

   public bool InvalidAge, StudentAge;

   [ExcludeFromEvaluation]
   public string MessageToEmployee;

   public void Display()
   {
      if(InvalidAge)
         this.MessageToEmployee =
            string.Format(this.template1, this.B, this.C);
      else if
         this.MessageToEmployee =
            string.Format(this.template2, this.B);
      else
         this.MessageToEmployee = "The validation has passed successfully";
   }
}
If
   A is lower than B or
   A is greater than C
      then
         set InvalidAge to True and
         Display
Else If
   A is lower than B
      then
         set StudentAge to True and
         Display
Else
   Display
。。。您可以这样创建规则:

public class Source
{
   private const string template1 = "Age must be between {0} and {1}";
   private const string template2 = "Student Age could be greater than {0}";

   public int A, B, C;

   public bool InvalidAge, StudentAge;

   [ExcludeFromEvaluation]
   public string MessageToEmployee;

   public void Display()
   {
      if(InvalidAge)
         this.MessageToEmployee =
            string.Format(this.template1, this.B, this.C);
      else if
         this.MessageToEmployee =
            string.Format(this.template2, this.B);
      else
         this.MessageToEmployee = "The validation has passed successfully";
   }
}
If
   A is lower than B or
   A is greater than C
      then
         set InvalidAge to True and
         Display
Else If
   A is lower than B
      then
         set StudentAge to True and
         Display
Else
   Display

我需要通过编辑器设置一条通用消息,如果属性值发生更改,它将根据它显示。实际上,我们希望客户也可以通过编辑器更新消息,并用另一种语言添加消息。如果int A=25,B=20,C=30,那么我的规则是这样的,如果AC,那么将消息设置为Employee Age可能在B和C之间,这样用户可以看到这样的消息:Employee Age可能在20和30之间。另一个信息可能是这样的:学生年龄可能大于B@MuhammadKhan请改进您的问题或考虑将我的帖子标记为“回答”,我想在编辑器中格式化消息,我可以通过编辑器绑定字符串/消息中的任何字段。例如,如果A小于B或A大于C,则设置Message=“年龄必须介于B和C之间”@MuhammadKhan,恐怕您无法使用当前存在的任何规则编辑器实现真正动态消息的功能。规则编辑器不是IDE,它们是为商务人士设计的。为了得到你想要的东西,你必须在你的规则中加入某种编程设计。谢谢Alex的澄清