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

问题描述

我需要根据规则编辑器中的参数字段值设置动态消息。 例如 如果A C,则将Message设置为A值应该在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