Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

rule engine - Dynamic list as parameter in Action

How I can create Dynamic list as parameter in Action to use it in function after then

        [Action("Send Email", "Send Email")]
    public void SendEmail(CaseRequest caserequest, [Parameter(ValueInputType.User, Description = "Output message")] List<string> ListEmail)
    {

        //Send Email
    }

Is doable to pass list of action , I need to it for this condition

if condition is true then sendEmail( display list of emails)

question from:https://stackoverflow.com/questions/65626712/dynamic-list-as-parameter-in-action

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In Code Effects, you can't just type a new list of strings directly in a method as param. You need to populate that list in your rule first and then pass it to the action method. Something like this:

public class Test
{
   public Test()
   {
      this.EmailList = new List<string>();
   }

   public List<string> ListEmail { private get; set; }

   public void AddEmail(string email)
   {
      if(string.IsNullOrEmpty(email)) return;
      this.ListEmail.Add(email);
   }

   public void SendEmail(CaseRequest caserequest, List<string> emails)
   {
      // Do your thing here...
   }
}

This allows you to create the following rule:

If
   Something equals to True
      then
         AddEmail("test1@test.com") and
         AddEmail("test2@test.com") and
         SendEmail(yourEnum, ListEmail)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...