using System.Threading.Tasks;
using RulesEngine.Actions;
using RulesEngine.Models;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public string Name {get;set;}
public int Score {get;set;}
public static void Main(){
var workflow = new WorkflowRules{
WorkflowName = "StrConcatWorkflow",
Actions = new RuleActions(){
OnSuccess = new ActionInfo{
Name = "OutputExpression",
Context = new Dictionary<string,object>{
{"Expression", "string.Join(\",\",input1.Select(c => c.Name+\"s\").Distinct())"}
Actions = new RuleActions(){
OnSuccess = new ActionInfo{
Name = "OutputExpression",
Context = new Dictionary<string,object>{
{"Expression", "string.Join(\",\",input1.Select(c => c.Score.ToString()).Distinct())"}
var resettings = new ReSettings{
CustomTypes = new Type[]{typeof(Regex)}
var re = new RulesEngine.RulesEngine(new []{workflow},resettings);
var input1 = new List<MyClass>(){
JArray o = (JArray)JToken.FromObject(input1);
var result = re.ExecuteAllRulesAsync("StrConcatWorkflow", input1).Result;
foreach(var res in result){
var output = res.ActionResult.Output;
Console.WriteLine($"{res.Rule.RuleName} :\nIsSuccess- {res.IsSuccess}\n {res.ExceptionMessage}");
Console.WriteLine($"Output : {output}\n");