Show The Code
using NRules;
using NRules.Fluent;
using System;
using System.Collections.Generic;
using System.Reflection;
public class RuleHepler
{
public static List<dynamic> RunRules(List<string> assemList, List<dynamic> ruleList)
{
var repos = new RuleRepository();
if(null== assemList || assemList.Count <= 0)
{
throw new Exception($"{nameof(assemList)} must not null");
}
var assemLoads = new List<Assembly>();
assemList.ForEach(assem=> {
var curAssem = Assembly.Load(assem);
assemLoads.Add(curAssem);
});
repos.Load(x => x.From(assemLoads));
var factory = repos.Compile();
var session = factory.CreateSession();
foreach(var obj in ruleList)
{
session.Insert(obj);
}
session.Fire();
return ruleList;
}
}
评论 (0)