Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 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 Answer

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("[email protected]") and
         AddEmail("[email protected]") and
         SendEmail(yourEnum, ListEmail)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...