using System.Threading.Tasks;
using RulesEngine.Actions;
using RulesEngine.Models;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;
using System.ComponentModel.DataAnnotations;
public class MyCustomObject
public MySubClass PropertyClass { get; set; }
public MySubClassList PropertyClassList { get; set; }
public class BaseSubClass
public string BaseProperty { get; set; }
public string MyProperty {get; set;}
public bool MyMethod(string value)
public class MySubClassList : List<BaseSubClass>
public string MyProp {get; set;} = "hello";
public bool MyMethod(string value){
public static class MySubClassListUtils{
public static bool MyMethodExt(MySubClassList mysubclassList, string value)
public static bool MyMethod(MySubClassList mysubclassList,string value){
return mysubclassList.MyMethod(value);
public static void Main(){
var workflow = new Workflow{
WorkflowName = "NestedClassTest",
RuleName = "NestedProperty",
Expression = "input1.PropertyClass.MyProperty == \"hello\""
RuleName = "NestedMethod",
Expression = "input1.PropertyClass.MyMethod(\"hello\")"
RuleName = "NestedMethodExtOnList",
Expression = "MySubClassListUtils.MyMethodExt(input1.PropertyClassList,\"hello\")"
RuleName = "NestedMethodOnList",
Expression = "MySubClassListUtils.MyMethod(input1.PropertyClassList,\"hello\")"
var resettings = new ReSettings{
typeof(MySubClassListUtils)
var re = new RulesEngine.RulesEngine(new []{workflow},resettings);
var input1 = new MyCustomObject{
PropertyClass = new MySubClass(){
PropertyClassList = new MySubClassList(){
var result = re.ExecuteAllRulesAsync("NestedClassTest", input1).Result;
foreach(var res in result){
var output = res.ActionResult.Output;
Console.WriteLine($"{res.Rule.RuleName} :\nIsSuccess- {res.IsSuccess}\n \n {res.ExceptionMessage}\n");