├── .gitignore ├── Backup ├── FluentFlow │ ├── ActivityProcessNode.cs │ ├── ConditionDecisionNode.cs │ ├── DecisionNode.cs │ ├── Flow.cs │ ├── FlowElement.cs │ ├── FlowNode.cs │ ├── FlowProcessNode.cs │ ├── FluentFlow.csproj │ ├── ProcessNode.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── TrueFalseNode.cs ├── RuleEngineTests │ ├── DslRuleTests.cs │ ├── FlowTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RubyRuleTests.cs │ ├── RuleEngineTests.csproj │ ├── RuleTests.cs │ └── packages.config ├── RulesEngine.BooEvaluator │ ├── BooLangEvaluator.cs │ ├── DslEngineStorage.cs │ ├── DslModel.cs │ ├── EvaluationContext.cs │ ├── IRuleDslEngineStorage.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RuleDslEngine.cs │ ├── RuleDslModel.cs │ └── RulesEngine.BooEvaluator.csproj ├── RulesEngine.IronRubyEvaluator │ ├── IronRubyEvaluator.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RubyClasses │ │ └── RuleRuleFactory.rb │ ├── RubyEngine.cs │ ├── RubyRule.cs │ ├── RulesEngine.IronRubyEvaluator.csproj │ └── packages.config ├── RulesEngine.Persistence │ ├── Properties │ │ └── AssemblyInfo.cs │ └── RulesEngine.Persistence.csproj ├── RulesEngine.sln └── RulesEngine │ ├── AbstractActivity.cs │ ├── AbstractCondition.cs │ ├── AbstractRule.cs │ ├── ActionActivity.cs │ ├── ActivityRule.cs │ ├── DslActivity.cs │ ├── DslCondition.cs │ ├── EvaluatorAccessPoint.cs │ ├── FuncCondition.cs │ ├── IDslConditionEvaluator.cs │ ├── Operation.cs │ ├── OperationRule.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Rule.cs │ ├── RuleSet.cs │ └── RulesEngine.csproj ├── FluentFlow ├── ActivityProcessNode.cs ├── ConditionDecisionNode.cs ├── DecisionNode.cs ├── Flow.cs ├── FlowElement.cs ├── FlowNode.cs ├── FlowProcessNode.cs ├── FluentFlow.csproj ├── ProcessNode.cs ├── Properties │ └── AssemblyInfo.cs └── TrueFalseNode.cs ├── README.markdown ├── RuleEngineTests ├── DslRuleTests.cs ├── FlowTests.cs ├── Properties │ └── AssemblyInfo.cs ├── RubyRuleTests.cs ├── RuleEngineTests.csproj ├── RuleTests.cs └── packages.config ├── RulesEngine.BooEvaluator ├── BooLangEvaluator.cs ├── DslEngineStorage.cs ├── DslModel.cs ├── EvaluationContext.cs ├── IRuleDslEngineStorage.cs ├── Properties │ └── AssemblyInfo.cs ├── RuleDslEngine.cs ├── RuleDslModel.cs └── RulesEngine.BooEvaluator.csproj ├── RulesEngine.IronRubyEvaluator ├── IronRubyEvaluator.cs ├── Properties │ └── AssemblyInfo.cs ├── RubyClasses │ └── RuleRuleFactory.rb ├── RubyEngine.cs ├── RubyRule.cs ├── RulesEngine.IronRubyEvaluator.csproj └── packages.config ├── RulesEngine.Persistence ├── Properties │ └── AssemblyInfo.cs └── RulesEngine.Persistence.csproj ├── RulesEngine.sln ├── RulesEngine ├── AbstractActivity.cs ├── AbstractCondition.cs ├── AbstractRule.cs ├── ActionActivity.cs ├── ActivityRule.cs ├── DslActivity.cs ├── DslCondition.cs ├── EvaluatorAccessPoint.cs ├── FuncCondition.cs ├── IDslConditionEvaluator.cs ├── Operation.cs ├── OperationRule.cs ├── Properties │ └── AssemblyInfo.cs ├── Rule.cs ├── RuleSet.cs └── RulesEngine.csproj ├── SharedLibs ├── Boo.Lang.Compiler.dll ├── Boo.Lang.Parser.dll ├── Boo.Lang.dll ├── Fluent │ ├── Antlr3.Runtime.dll │ ├── Castle.Core.dll │ ├── Castle.DynamicProxy2.dll │ ├── FluentNHibernate.dll │ ├── Iesi.Collections.dll │ ├── NHibernate.ByteCode.Castle.dll │ ├── NHibernate.dll │ └── log4net.dll ├── Rhino.DSL.dll └── nunit.framework.dll ├── UpgradeLog.XML ├── _UpgradeReport_Files ├── UpgradeReport.css ├── UpgradeReport.xslt ├── UpgradeReport_Minus.gif └── UpgradeReport_Plus.gif └── packages ├── IronRuby.1.1.2 ├── IronRuby.1.1.2.nupkg └── Lib │ ├── IronRuby.Libraries.Yaml.dll │ ├── IronRuby.Libraries.dll │ ├── IronRuby.dll │ ├── Microsoft.Dynamic.dll │ ├── Microsoft.Scripting.Metadata.dll │ └── Microsoft.Scripting.dll └── repositories.config /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | bin 3 | deploy 4 | deploy/* 5 | _ReSharper.* 6 | *.csproj.user 7 | *.resharper.user 8 | *.resharper 9 | *.suo 10 | *.cache 11 | ~$* -------------------------------------------------------------------------------- /Backup/FluentFlow/ActivityProcessNode.cs: -------------------------------------------------------------------------------- 1 | using RulesEngine; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ActivityProcessNode : ProcessNode 6 | { 7 | private AbstractActivity activity; 8 | public ActivityProcessNode(AbstractActivity activity, FlowElement master) 9 | : base(master) 10 | { 11 | this.activity = activity; 12 | } 13 | 14 | internal override void Evaluate(T instance) 15 | { 16 | if (this.activity != null) activity.Execute(instance); 17 | base.Evaluate(instance); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/ConditionDecisionNode.cs: -------------------------------------------------------------------------------- 1 | using RulesEngine; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ConditionDecisionNode : DecisionNode 6 | { 7 | private AbstractCondition condition; 8 | 9 | public ConditionDecisionNode(AbstractCondition condition, FlowElement master) 10 | : base(master) 11 | { 12 | this.condition = condition; 13 | } 14 | 15 | protected override bool Condition(T instance) 16 | { 17 | return condition.Evaluate(instance); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/DecisionNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public abstract class DecisionNode : FlowElement 6 | { 7 | private TrueFalseNode trueNode; 8 | private FalseTrueNode falseNode; 9 | 10 | protected DecisionNode(FlowElement master) : base(master) 11 | { 12 | } 13 | 14 | public TrueFalseNode WhenTrue(Action> action) 15 | { 16 | trueNode = new TrueFalseNode(action, master); 17 | return trueNode; 18 | } 19 | 20 | public FalseTrueNode WhenFalse(Action> action) 21 | { 22 | falseNode = new FalseTrueNode(action, master); 23 | return falseNode; 24 | } 25 | 26 | protected abstract bool Condition(T instance); 27 | 28 | internal override void Evaluate(T instance) 29 | { 30 | var branchNode = trueNode ?? (falseNode ?? (DicisionBranchNode)null); 31 | if (branchNode == null) return; 32 | 33 | if(this.Condition(instance)) 34 | branchNode.Evaluate(instance); 35 | else 36 | branchNode.EvaluateOtherResult(instance); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/Flow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public static class Flow 6 | { 7 | public static FlowNode For() 8 | { 9 | return new FlowNode(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/FlowElement.cs: -------------------------------------------------------------------------------- 1 | namespace FluentFlow 2 | { 3 | public abstract class FlowElement 4 | { 5 | protected FlowElement master; 6 | 7 | protected FlowElement() 8 | { 9 | master = this; 10 | } 11 | 12 | protected FlowElement(FlowElement master) 13 | { 14 | this.master = master; 15 | } 16 | internal abstract void Evaluate(T instance); 17 | 18 | public virtual void Execute(T instance) 19 | { 20 | if(this.master != null) 21 | this.master.Evaluate(instance); 22 | else 23 | this.Evaluate(instance); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/FlowNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RulesEngine; 3 | 4 | namespace FluentFlow 5 | { 6 | public class FlowNode : FlowElement 7 | { 8 | private DecisionNode decisionNode; 9 | private ProcessNode actionNode; 10 | 11 | public FlowNode() 12 | { 13 | } 14 | 15 | public FlowNode(FlowElement master): base(master) 16 | { 17 | } 18 | 19 | internal override void Evaluate(T instance) 20 | { 21 | if (decisionNode != null) decisionNode.Evaluate(instance); 22 | if (actionNode != null) actionNode.Evaluate(instance); 23 | } 24 | 25 | public DecisionNode Decide(Func func) 26 | { 27 | decisionNode = new ConditionDecisionNode(new FuncCondition(func), master); 28 | return decisionNode; 29 | } 30 | 31 | public DecisionNode Decide(TCondition condition) where TCondition : AbstractCondition 32 | { 33 | decisionNode = new ConditionDecisionNode(condition, master); 34 | return decisionNode; 35 | } 36 | 37 | public ProcessNode Do(Action> action) 38 | { 39 | actionNode = new FlowProcessNode(action, master); 40 | return actionNode; 41 | } 42 | 43 | public ProcessNode Do(Action action) 44 | { 45 | actionNode = new ActivityProcessNode(new ActionActivity(action), master); 46 | return actionNode; 47 | } 48 | 49 | public ProcessNode Do(AbstractActivity activity) 50 | { 51 | actionNode = new ActivityProcessNode(activity, master); 52 | return actionNode; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/FlowProcessNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class FlowProcessNode : ProcessNode 6 | { 7 | private Action> action; 8 | public FlowProcessNode(Action> action, FlowElement master) 9 | : base(master) 10 | { 11 | this.action = action; 12 | } 13 | 14 | internal override void Evaluate(T instance) 15 | { 16 | if (action != null) 17 | { 18 | var flowNode = new FlowNode(master); 19 | action(flowNode); 20 | flowNode.Evaluate(instance); 21 | } 22 | base.Evaluate(instance); 23 | } 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/FluentFlow.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {1EE600CA-741A-4968-933C-859787B8010C} 9 | Library 10 | Properties 11 | FluentFlow 12 | FluentFlow 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 3.5 37 | 38 | 39 | 3.5 40 | 41 | 42 | 3.5 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 62 | RulesEngine 63 | 64 | 65 | 66 | 73 | -------------------------------------------------------------------------------- /Backup/FluentFlow/ProcessNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ProcessNode : FlowElement 6 | { 7 | private Action> continuedAction; 8 | private Action finalAction; 9 | private FlowNode then; 10 | 11 | public ProcessNode(FlowElement master) : base(master) 12 | { 13 | } 14 | 15 | public FlowNode Then 16 | { 17 | get 18 | { 19 | if (then == null) then = new FlowNode(master); 20 | return then; 21 | } 22 | } 23 | 24 | internal override void Evaluate(T instance) 25 | { 26 | if (then != null) then.Evaluate(instance); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Backup/FluentFlow/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FluentFlow")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FluentFlow")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c9a54f16-2a91-4408-8b48-ee5b63ab50df")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/FluentFlow/TrueFalseNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class DicisionBranchNode : FlowProcessNode 6 | { 7 | protected ProcessNode onOtherResult; 8 | 9 | public DicisionBranchNode(Action> action, FlowElement master) 10 | : base(action, master) 11 | { 12 | } 13 | 14 | public void EvaluateOtherResult(T instance) 15 | { 16 | if(onOtherResult != null) onOtherResult.Evaluate(instance); 17 | } 18 | } 19 | 20 | public class TrueFalseNode : DicisionBranchNode 21 | { 22 | public TrueFalseNode(Action> action, FlowElement master) 23 | : base(action, master) 24 | { 25 | } 26 | 27 | public ProcessNode WhenFalse(Action> action) 28 | { 29 | onOtherResult = new FlowProcessNode(action, master); 30 | return onOtherResult; 31 | } 32 | } 33 | 34 | public class FalseTrueNode : DicisionBranchNode 35 | { 36 | public FalseTrueNode(Action> action, FlowElement master) 37 | : base(action, master) 38 | { 39 | } 40 | 41 | public ProcessNode WhenTrue(Action> action) 42 | { 43 | onOtherResult = new FlowProcessNode(action, master); 44 | return onOtherResult; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Backup/RuleEngineTests/DslRuleTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RulesEngine; 3 | using RulesEngine.BooEvaluator; 4 | 5 | namespace RuleEngineTests 6 | { 7 | [TestFixture] 8 | public class DslRuleTests 9 | { 10 | private BooLangEvaluator evaluator; 11 | 12 | [SetUp] 13 | public void Setup() 14 | { 15 | var dslEngineStorage = new DslEngineStorage(); 16 | evaluator = new BooLangEvaluator(dslEngineStorage); 17 | } 18 | 19 | [Test] 20 | public void Can_Evaluate_Dsl_Expression() 21 | { 22 | var rule = "return (this.Price > 20 or this.Price < 15)"; 23 | var order = new Order { Price = 10, Message = "Soemthing" }; 24 | var result = evaluator.Evaluate(rule, order); 25 | Assert.IsTrue(result); 26 | } 27 | 28 | [Test] 29 | public void Can_Evaluate_Expression_As_ConditionalRule() 30 | { 31 | var statement = "return (this.Price > 20 or this.Price < 15)"; 32 | var order = new Order { Price = 10, Message = "Soemthing" }; 33 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 34 | var condition = new DslCondition { DslStatement = statement }; 35 | var rule = new ConditionalRule(condition); 36 | Assert.IsTrue(rule.Evaluate(order)); 37 | } 38 | 39 | [Test] 40 | public void Can_Evaluate_Expression_As_ActionActivityRule() 41 | { 42 | var statement = "return (this.Price > 20 or this.Price < 15)"; 43 | var order = new Order { Price = 10, Message = "Soemthing" }; 44 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 45 | var condition = new DslCondition { DslStatement = statement }; 46 | var rule = new ActivityRule(condition, new ActionActivity(t => 47 | { 48 | t.Message = "amp"; 49 | })); 50 | Assert.IsTrue(rule.Evaluate(order)); 51 | Assert.AreEqual("amp", order.Message); 52 | } 53 | 54 | [Test] 55 | public void Can_Evaluate_Expression_With_DslActivity() 56 | { 57 | var statement = "return (this.Price > 20 or this.Price < 15)"; 58 | var order = new Order { Price = 10, Message = "Something" }; 59 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 60 | var condition = new DslCondition { DslStatement = statement }; 61 | var rule = new ActivityRule(condition, new DslActivity 62 | { 63 | DslStatement = @" 64 | this.Message = ""dsl""; 65 | return true;" 66 | }); 67 | Assert.IsTrue(rule.Evaluate(order)); 68 | Assert.AreEqual("dsl", order.Message); 69 | } 70 | 71 | [Test] 72 | public void Can_Evaluate_Expression_With_FuncCondition() 73 | { 74 | var order = new Order { Price = 10, Message = "Something" }; 75 | var condition = new FuncCondition(o => o.Price < 20); 76 | var rule = new ActivityRule(condition, new ActionActivity(t => 77 | { 78 | t.Message = "amp"; 79 | })); 80 | Assert.IsTrue(rule.Evaluate(order)); 81 | Assert.AreEqual("amp", order.Message); 82 | } 83 | } 84 | 85 | public class Order 86 | { 87 | public int Price; 88 | public string Message; 89 | } 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /Backup/RuleEngineTests/FlowTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentFlow; 3 | using NUnit.Framework; 4 | using RulesEngine; 5 | using RulesEngine.BooEvaluator; 6 | 7 | namespace RuleEngineTests 8 | { 9 | [TestFixture] 10 | public class FlowTests 11 | { 12 | private BooLangEvaluator evaluator; 13 | 14 | [SetUp] 15 | public void Setup() 16 | { 17 | var dslEngineStorage = new DslEngineStorage(); 18 | evaluator = new BooLangEvaluator(dslEngineStorage); 19 | } 20 | 21 | [Test] 22 | public void Can_Setup_Flow() 23 | { 24 | var flow = Flow.For() 25 | .Do(a => 26 | a.Price = 10) 27 | .Then 28 | .Decide(o => o.Price > 10) 29 | .WhenTrue(a => a.Do(t => t.Price = 10) 30 | .Then 31 | .Decide(aa => aa.Price > 15) 32 | .WhenTrue(b => b.Do(t => t.Price = 20)) 33 | .WhenFalse(b => b.Do(t => t.Price = 30)) 34 | ) 35 | .WhenFalse(a1 => a1.Do(t => t.Price = 30) 36 | .Then.Do(t => t.Price = 40).Then.Do(t => t.Price = 50).Then 37 | .Decide(aa => aa.Price > 40).WhenFalse(a => a.Do(a2 => a2.Message ="test"))); 38 | 39 | var order = new Order {Price = 15}; 40 | flow.Execute(order); 41 | Console.WriteLine(order.Price); 42 | Console.WriteLine(order.Message); 43 | } 44 | 45 | [Test] 46 | public void Can_Setup_Flow_With_Dsl_Conditions() 47 | { 48 | var statement = "return (this.Price > 15 and this.Price < 20)"; 49 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 50 | 51 | var flow = Flow.For() 52 | .Decide(new DslCondition(statement)) 53 | .WhenTrue(a => a.Do(o => o.Message = "true")) 54 | .WhenFalse(a => a.Do(o => o.Message = "false")); 55 | 56 | var order = new Order { Price = 16 }; 57 | flow.Execute(order); 58 | Assert.AreEqual("true", order.Message); 59 | order.Price = 21; 60 | flow.Execute(order); 61 | Assert.AreEqual("false", order.Message); 62 | } 63 | 64 | [Test] 65 | public void Can_Setup_Flow_With_Dsl_Conditions_And_DslActiviy() 66 | { 67 | var condition = "return (this.Price > 15 and this.Price < 20)"; 68 | var activity = @"this.Message = ""true""; return true; "; 69 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 70 | 71 | var flow = Flow.For() 72 | .Decide(new DslCondition(condition)) 73 | .WhenTrue(a => a.Do(new DslActivity(activity))) 74 | .WhenFalse(a => a.Do(o => o.Message = "false")); 75 | 76 | var order = new Order { Price = 16 }; 77 | flow.Execute(order); 78 | Assert.AreEqual("true", order.Message); 79 | order.Price = 21; 80 | flow.Execute(order); 81 | Assert.AreEqual("false", order.Message); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /Backup/RuleEngineTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RuleEngineTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RuleEngineTests")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("40a065ff-52b7-4e05-a757-830ecafd4b7c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/RuleEngineTests/RubyRuleTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using NUnit.Framework; 4 | using RulesEngine; 5 | using RulesEngine.BooEvaluator; 6 | using RulesEngine.IronRubyEvaluator; 7 | 8 | namespace RuleEngineTests 9 | { 10 | [TestFixture] 11 | public class RubyRuleTests 12 | { 13 | private IronRubyEvaluator evaluator; 14 | 15 | [SetUp] 16 | public void Setup() 17 | { 18 | evaluator = new IronRubyEvaluator(); 19 | } 20 | 21 | [Test] 22 | public void Can_Evaluate_Ruby_Expression() 23 | { 24 | var rule = "this.Price > 20 or this.Price < 15"; 25 | var order = new Order { Price = 10, Message = "Soemthing" }; 26 | var result = evaluator.Evaluate(rule, order); 27 | Assert.IsTrue(result); 28 | } 29 | 30 | [Test] 31 | public void Can_Evaluate_Ruby_Expression_Again() 32 | { 33 | var rule = "this.Price > 20 and this.Price < 15"; 34 | var order = new Order { Price = 10, Message = "Soemthing" }; 35 | var result = evaluator.Evaluate(rule, order); 36 | Assert.IsFalse(result); 37 | } 38 | 39 | [Test] 40 | public void Can_Evaluate_Ruby_Expression_On_CardInfo_Context() 41 | { 42 | var rule = "this.IsVisa"; 43 | var context = new CardInfo {IsVisa = true}; 44 | var result = evaluator.Evaluate(rule, context); 45 | Assert.IsTrue(result); 46 | 47 | context = new CardInfo { IsVisa = false }; 48 | result = evaluator.Evaluate(rule, context); 49 | Assert.IsFalse(result); 50 | } 51 | } 52 | 53 | public class CardInfo 54 | { 55 | public bool IsVisa; 56 | } 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /Backup/RuleEngineTests/RuleEngineTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {870370DF-A640-4188-BDDD-AB1CCE2A568E} 9 | Library 10 | Properties 11 | RuleEngineTests 12 | RuleEngineTests 13 | v4.0 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.dll 41 | 42 | 43 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.dll 44 | 45 | 46 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.Yaml.dll 47 | 48 | 49 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Dynamic.dll 50 | 51 | 52 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.dll 53 | 54 | 55 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.Metadata.dll 56 | 57 | 58 | False 59 | ..\SharedLibs\nunit.framework.dll 60 | 61 | 62 | False 63 | ..\SharedLibs\Rhino.DSL.dll 64 | 65 | 66 | 67 | 3.5 68 | 69 | 70 | 3.5 71 | 72 | 73 | 3.5 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | {1EE600CA-741A-4968-933C-859787B8010C} 88 | FluentFlow 89 | 90 | 91 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1} 92 | RulesEngine.BooEvaluator 93 | 94 | 95 | {6CD480C0-8459-4C81-8A11-BD63546A8F33} 96 | RulesEngine.IronRubyEvaluator 97 | 98 | 99 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 100 | RulesEngine 101 | 102 | 103 | 104 | 105 | 106 | 107 | 114 | -------------------------------------------------------------------------------- /Backup/RuleEngineTests/RuleTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RulesEngine; 3 | 4 | namespace RuleEngineTests 5 | { 6 | [TestFixture] 7 | public class RuleTests 8 | { 9 | [Test] 10 | public void Can_Add_Rules() 11 | { 12 | var rule1 = new ConditionalRule(new FuncCondition(t => true)); 13 | var rule2 = new ConditionalRule(new FuncCondition(t => false)); 14 | 15 | var rule = rule1 & rule2; 16 | Assert.IsFalse(rule.Evaluate(10)); 17 | } 18 | 19 | [Test] 20 | public void Can_Or_Rules() 21 | { 22 | var rule1 = new ConditionalRule(new FuncCondition(t => true)); 23 | var rule2 = new ConditionalRule(new FuncCondition(t => false)); 24 | 25 | var rule = rule1 | rule2; 26 | Assert.IsTrue(rule.Evaluate(10)); 27 | } 28 | 29 | [Test] 30 | public void Can_Do_Complex_Rule() 31 | { 32 | var rule1 = new ConditionalRule(new FuncCondition(t => true)){ Name = "rule1" }; 33 | var rule2 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule2" }; 34 | var rule3 = new ConditionalRule(new FuncCondition(t => true)) { Name = "rule3" }; 35 | var rule4 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule4" }; 36 | var rule5 = new ConditionalRule(new FuncCondition(t => true)) { Name = "rule5" }; 37 | var rule6 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule6" }; 38 | 39 | var rule = (rule1 & rule2) | ( (rule3 | rule4) & (rule5 | rule6) ); 40 | Assert.IsTrue(rule.Evaluate(10)); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Backup/RuleEngineTests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/BooLangEvaluator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Rhino.DSL; 4 | 5 | namespace RulesEngine.BooEvaluator 6 | { 7 | public class BooLangEvaluator : IDslConditionEvaluator 8 | { 9 | private Dictionary parsedModels; 10 | private RuleDslEngine ruleDslEngine; 11 | private DslFactory dslFactory; 12 | private IRuleDslEngineStorage dslEngineStorage; 13 | 14 | public BooLangEvaluator(IRuleDslEngineStorage dslEngineStorage) 15 | { 16 | parsedModels = new Dictionary(); 17 | ruleDslEngine = new RuleDslEngine(); 18 | ruleDslEngine.Storage = dslEngineStorage; 19 | dslFactory = new DslFactory(); 20 | dslFactory.Register(ruleDslEngine); 21 | this.dslEngineStorage = dslEngineStorage; 22 | } 23 | 24 | public bool Evaluate(string condition, T context) 25 | { 26 | EvaluationContext.CurrentContext = context; 27 | DslModel model = null; 28 | if (!parsedModels.ContainsKey(condition)) 29 | { 30 | model = CreateRuleModelFor(condition); 31 | parsedModels.Add(condition, model); 32 | } 33 | else 34 | { 35 | model = parsedModels[condition]; 36 | } 37 | return model.Evaluate(); 38 | } 39 | 40 | private DslModel CreateRuleModelFor(string condition) 41 | { 42 | DslModel model = null; 43 | lock(dslFactory) 44 | { 45 | var wrapperRule = String.Format(@" 46 | evaluate: 47 | {0} 48 | ", condition); 49 | var url = dslEngineStorage.AddCondition(wrapperRule); 50 | model = dslFactory.TryCreate(url); 51 | model.Initialize(); 52 | } 53 | return model; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/DslEngineStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Boo.Lang.Compiler.IO; 4 | using Rhino.DSL; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public class DslEngineStorage : IRuleDslEngineStorage 9 | { 10 | private string condition; 11 | 12 | public string AddCondition(string condition) 13 | { 14 | this.condition = condition; 15 | return typeof(RuleDslModel).Name; 16 | } 17 | 18 | public Boo.Lang.Compiler.ICompilerInput CreateInput(string url) 19 | { 20 | return new StringInput(url, condition); 21 | } 22 | 23 | public string GetChecksumForUrls(System.Type dslEngineType, System.Collections.Generic.IEnumerable urls) 24 | { 25 | return typeof(RuleDslModel).Name + "_" + dslEngineType.Name; 26 | } 27 | 28 | public string[] GetMatchingUrlsIn(string parentPath, ref string url) 29 | { 30 | return new [] { url }; 31 | } 32 | 33 | public string GetTypeNameFromUrl(string url) 34 | { 35 | return typeof(RuleDslModel).Name; 36 | } 37 | 38 | public bool IsUrlIncludeIn(string[] urls, string parentPath, string url) 39 | { 40 | return Array.IndexOf(urls, url) >= 0; 41 | } 42 | 43 | public bool IsValidScriptUrl(string url) 44 | { 45 | return true; 46 | } 47 | 48 | public void NotifyOnChange(System.Collections.Generic.IEnumerable urls, System.Action action) 49 | { 50 | 51 | } 52 | 53 | public void Dispose() 54 | { 55 | 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/DslModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Boo.Lang; 3 | using Boo.Lang.Compiler; 4 | using Boo.Lang.Compiler.Ast; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public abstract class DslModel 9 | { 10 | private Func evaluation; 11 | 12 | public DslModel() 13 | {} 14 | 15 | public abstract void Prepare(); 16 | 17 | public void Initialize() 18 | { 19 | Prepare(); 20 | } 21 | 22 | [Meta] 23 | public static Expression evaluate(BlockExpression formula) 24 | { 25 | var body = new Block(formula.LexicalInfo); 26 | for (int i = 0; i < formula.Body.Statements.Count; ++i) 27 | { 28 | var statement = formula.Body.Statements[i]; 29 | 30 | if (statement is ExpressionStatement && 31 | i == formula.Body.Statements.Count - 1) 32 | { 33 | var last = (ExpressionStatement)statement; 34 | body.Statements.Add(new ReturnStatement(last.Expression)); 35 | } 36 | else 37 | body.Statements.Add(formula.Body.Statements[i]); 38 | } 39 | 40 | var result = new BlockExpression(body); 41 | result.Parameters.Add(new ParameterDeclaration("this", 42 | CompilerContext.Current.CodeBuilder 43 | .CreateTypeReference(EvaluationContext.CurrentContext.GetType()))); 44 | result.ReturnType = CompilerContext.Current.CodeBuilder 45 | .CreateTypeReference(typeof(bool)); 46 | 47 | return new MethodInvocationExpression( 48 | new ReferenceExpression("SetEvaluationFunction"), result); 49 | } 50 | 51 | protected void SetEvaluationFunction(Func evaluation) 52 | { 53 | this.evaluation = evaluation; 54 | } 55 | 56 | public bool Evaluate() 57 | { 58 | return this.evaluation(EvaluationContext.CurrentContext); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/EvaluationContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RulesEngine.BooEvaluator 4 | { 5 | public static class EvaluationContext 6 | { 7 | public static object CurrentContext { get; set;} 8 | } 9 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/IRuleDslEngineStorage.cs: -------------------------------------------------------------------------------- 1 | using Rhino.DSL; 2 | 3 | namespace RulesEngine.BooEvaluator 4 | { 5 | public interface IRuleDslEngineStorage : IDslEngineStorage 6 | { 7 | string AddCondition(string condition); 8 | } 9 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.BooEvaluator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine.BooEvaluator")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2973bddf-cbd6-4bfc-ac32-0a0174a44d41")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/RuleDslEngine.cs: -------------------------------------------------------------------------------- 1 | using Boo.Lang.Compiler; 2 | using Boo.Lang.Compiler.IO; 3 | using Boo.Lang.Compiler.Pipelines; 4 | using Rhino.DSL; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public class RuleDslEngine : DslEngine where M : DslModel 9 | { 10 | public override CompilerContext ForceCompile(string[] urls, string cacheFileName) 11 | { 12 | var booCompiler = new BooCompiler(); 13 | booCompiler.Parameters.OutputType = CompilerOutputType; 14 | booCompiler.Parameters.GenerateInMemory = true; 15 | booCompiler.Parameters.Pipeline = new CompileToMemory(); 16 | CustomizeCompiler(booCompiler, booCompiler.Parameters.Pipeline, new string[]{}); 17 | AddInputs(urls, booCompiler); 18 | var compilerContext = booCompiler.Run(); 19 | CompileCompleted(compilerContext); 20 | return compilerContext; 21 | } 22 | 23 | protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls) 24 | { 25 | compiler.Parameters.AddAssembly(typeof(BooCompiler).Assembly); 26 | compiler.Parameters.Ducky = true; 27 | pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof (M), "Prepare")); 28 | base.CustomizeCompiler(compiler, pipeline, urls); 29 | } 30 | 31 | private void AddInputs(string[] urls, BooCompiler compiler) 32 | { 33 | foreach (var url in urls) 34 | { 35 | compiler.Parameters.Input.Add(Storage.CreateInput(url)); 36 | } 37 | } 38 | 39 | private void CompileCompleted(CompilerContext context) 40 | { 41 | if(context.Errors.Count != 0) 42 | { 43 | throw CreateCompilerException(context); 44 | } 45 | HandleWarnings(context.Warnings); 46 | } 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/RuleDslModel.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine.BooEvaluator 2 | { 3 | public abstract class RuleDslModel : DslModel 4 | { 5 | public RuleDslModel() 6 | {} 7 | } 8 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.BooEvaluator/RulesEngine.BooEvaluator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1} 9 | Library 10 | Properties 11 | RulesEngine.BooEvaluator 12 | RulesEngine.BooEvaluator 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | False 36 | ..\SharedLibs\Boo.Lang.dll 37 | 38 | 39 | False 40 | ..\SharedLibs\Boo.Lang.Compiler.dll 41 | 42 | 43 | False 44 | ..\SharedLibs\Boo.Lang.Parser.dll 45 | 46 | 47 | False 48 | ..\SharedLibs\Rhino.DSL.dll 49 | 50 | 51 | 52 | 3.5 53 | 54 | 55 | 3.5 56 | 57 | 58 | 3.5 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 76 | RulesEngine 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/IronRubyEvaluator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | 4 | namespace RulesEngine.IronRubyEvaluator 5 | { 6 | public class IronRubyEvaluator : IDslConditionEvaluator 7 | { 8 | public IronRubyEvaluator() 9 | { 10 | } 11 | 12 | public bool Evaluate(string condition, T context) 13 | { 14 | var ruleEngine = new RubyEngine(context.GetType(), condition); 15 | var rule = ruleEngine.Create(); 16 | return rule.Evaluate(context); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.IronRubyEvaluator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RulesEngine.IronRubyEvaluator")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9600ea41-d3a8-40b1-b853-d09aee8cd100")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/RubyClasses/RuleRuleFactory.rb: -------------------------------------------------------------------------------- 1 | include RulesEngine 2 | include RulesEngine::IronRubyEvaluator 3 | include $ruleAssembly$ 4 | 5 | class RuleRuleFactory 6 | 7 | def Create() 8 | internalCreate $contextType$, do |this| $condition$ end 9 | end 10 | 11 | def internalCreate(type, &condition) 12 | RubyRule.of(type).new condition 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/RubyEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Reflection; 6 | using IronRuby; 7 | using Microsoft.Scripting.Hosting; 8 | 9 | namespace RulesEngine.IronRubyEvaluator 10 | { 11 | public class RubyEngine 12 | { 13 | private readonly string dslFileName; 14 | private readonly List assemblies; 15 | private Type contextType; 16 | private string condition; 17 | private ScriptEngine engine; 18 | private ScriptSource source; 19 | 20 | public RubyEngine(Type type, string condition) 21 | { 22 | contextType = type; 23 | this.condition = condition; 24 | this.dslFileName = "RubyClasses\\RuleRuleFactory.rb"; 25 | this.assemblies = new List 26 | { 27 | typeof(AbstractRule).Assembly, 28 | typeof(RubyEngine).Assembly, 29 | type.Assembly 30 | }; 31 | } 32 | 33 | public ICondition Create() 34 | { 35 | this.engine = Ruby.CreateEngine(); 36 | var rubyRuleTemplate = String.Empty; 37 | using(var stream = new StreamReader(this.dslFileName)) 38 | { 39 | rubyRuleTemplate = stream.ReadToEnd(); 40 | } 41 | rubyRuleTemplate = rubyRuleTemplate.Replace("$ruleAssembly$", this.contextType.Namespace.Replace(".", "::")); 42 | rubyRuleTemplate = rubyRuleTemplate.Replace("$contextType$", this.contextType.Name); 43 | rubyRuleTemplate = rubyRuleTemplate.Replace("$condition$", this.condition); 44 | this.source = engine.CreateScriptSourceFromString(rubyRuleTemplate); 45 | 46 | var scope = engine.CreateScope(); 47 | assemblies.ForEach(a => engine.Runtime.LoadAssembly(a)); 48 | 49 | engine.Execute(source.GetCode(), scope); 50 | var @class = engine.Runtime.Globals.GetVariable("RuleRuleFactory"); 51 | 52 | var installer = engine.Operations.CreateInstance(@class); 53 | var rule = installer.Create(); 54 | 55 | return (ICondition) rule; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/RubyRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace RulesEngine.IronRubyEvaluator 7 | { 8 | public interface ICondition 9 | { 10 | bool Evaluate(object arg); 11 | } 12 | 13 | public class RubyRule : ICondition 14 | { 15 | private readonly Predicate evaluation; 16 | 17 | public RubyRule(Func evaluation) 18 | { 19 | this.evaluation = x => (x is Func) ? 20 | evaluation.Invoke(((Func)x).Invoke()) : 21 | (x is TContext) ? 22 | evaluation.Invoke((TContext)x) : false; 23 | } 24 | 25 | public bool Evaluate(object arg) 26 | { 27 | return evaluation(arg); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/RulesEngine.IronRubyEvaluator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {6CD480C0-8459-4C81-8A11-BD63546A8F33} 9 | Library 10 | Properties 11 | RulesEngine.IronRubyEvaluator 12 | RulesEngine.IronRubyEvaluator 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.dll 36 | 37 | 38 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.dll 39 | 40 | 41 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.Yaml.dll 42 | 43 | 44 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Dynamic.dll 45 | 46 | 47 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.dll 48 | 49 | 50 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.Metadata.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 69 | RulesEngine 70 | 71 | 72 | 73 | 74 | Designer 75 | 76 | 77 | Always 78 | 79 | 80 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /Backup/RulesEngine.IronRubyEvaluator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Backup/RulesEngine.Persistence/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.Persistence")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine.Persistence")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6dfbd04c-2f63-4ad1-871e-d75272acdd2f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/RulesEngine.Persistence/RulesEngine.Persistence.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {0B37F672-A5CB-493B-AE58-F1529033D0D9} 9 | Library 10 | Properties 11 | RulesEngine.Persistence 12 | RulesEngine.Persistence 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | False 36 | ..\SharedLibs\Fluent\Castle.Core.dll 37 | 38 | 39 | False 40 | ..\SharedLibs\Fluent\Castle.DynamicProxy2.dll 41 | 42 | 43 | False 44 | ..\SharedLibs\Fluent\FluentNHibernate.dll 45 | 46 | 47 | False 48 | ..\SharedLibs\Fluent\NHibernate.dll 49 | 50 | 51 | False 52 | ..\SharedLibs\Fluent\NHibernate.ByteCode.Castle.dll 53 | 54 | 55 | 56 | 3.5 57 | 58 | 59 | 3.5 60 | 61 | 62 | 3.5 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | -------------------------------------------------------------------------------- /Backup/RulesEngine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine", "RulesEngine\RulesEngine.csproj", "{05453C09-F3DB-46EF-851C-0AB0AC766955}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuleEngineTests", "RuleEngineTests\RuleEngineTests.csproj", "{870370DF-A640-4188-BDDD-AB1CCE2A568E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.BooEvaluator", "RulesEngine.BooEvaluator\RulesEngine.BooEvaluator.csproj", "{535D3A6C-9293-4CC6-8E44-76EEC136D0D1}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.Persistence", "RulesEngine.Persistence\RulesEngine.Persistence.csproj", "{0B37F672-A5CB-493B-AE58-F1529033D0D9}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentFlow", "FluentFlow\FluentFlow.csproj", "{1EE600CA-741A-4968-933C-859787B8010C}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.IronRubyEvaluator", "RulesEngine.IronRubyEvaluator\RulesEngine.IronRubyEvaluator.csproj", "{6CD480C0-8459-4C81-8A11-BD63546A8F33}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {1EE600CA-741A-4968-933C-859787B8010C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {1EE600CA-741A-4968-933C-859787B8010C}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {1EE600CA-741A-4968-933C-859787B8010C}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {1EE600CA-741A-4968-933C-859787B8010C}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Release|Any CPU.Build.0 = Release|Any CPU 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /Backup/RulesEngine/AbstractActivity.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public abstract class AbstractActivity 4 | { 5 | public abstract void Execute(object context); 6 | } 7 | 8 | public abstract class AbstractActivity : AbstractActivity 9 | { 10 | public abstract void Execute(T context); 11 | } 12 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/AbstractCondition.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public abstract class AbstractCondition 4 | { 5 | public abstract bool Evaluate(object context); 6 | } 7 | 8 | public abstract class AbstractCondition : AbstractCondition 9 | { 10 | public abstract bool Evaluate(T context); 11 | } 12 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/AbstractRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public abstract class AbstractRule 6 | { 7 | public abstract bool Evaluate(T context); 8 | public string Name { get; set; } 9 | 10 | 11 | public static AbstractRule operator &(AbstractRule rule1, AbstractRule rule2) 12 | { 13 | return new OperationRule(rule1, rule2, Operation.And); 14 | } 15 | 16 | public static AbstractRule operator |(AbstractRule rule1, AbstractRule rule2) 17 | { 18 | return new OperationRule(rule1, rule2, Operation.Or); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/ActionActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public class ActionActivity : AbstractActivity 6 | { 7 | private Action action; 8 | 9 | public ActionActivity(Action action) 10 | { 11 | this.action = action; 12 | } 13 | 14 | public override void Execute(object context) 15 | { 16 | this.action((T) context); 17 | } 18 | 19 | public override void Execute(T context) 20 | { 21 | this.action(context); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/ActivityRule.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class ActivityRule : ConditionalRule 4 | { 5 | private AbstractActivity activity; 6 | 7 | public ActivityRule(AbstractCondition condition, 8 | AbstractActivity activity) : base(condition) 9 | { 10 | this.activity = activity; 11 | } 12 | 13 | public override bool Evaluate(T context) 14 | { 15 | if(base.Evaluate(context)) 16 | { 17 | this.activity.Execute(context); 18 | return true; 19 | } 20 | return false; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/DslActivity.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class DslActivity : AbstractActivity 4 | { 5 | public string DslStatement { get; set; } 6 | 7 | public DslActivity(){} 8 | 9 | public DslActivity(string statement) 10 | { 11 | this.DslStatement = statement; 12 | } 13 | 14 | public override void Execute(object context) 15 | { 16 | if(EvaluatorAccessPoint.DslConditionEvaluator != null) 17 | EvaluatorAccessPoint.DslConditionEvaluator.Evaluate(DslStatement, context); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/DslCondition.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class DslCondition : AbstractCondition 4 | { 5 | public string DslStatement { get; set; } 6 | 7 | public DslCondition(){} 8 | 9 | public DslCondition(string statement) 10 | { 11 | this.DslStatement = statement; 12 | } 13 | 14 | public override bool Evaluate(object context) 15 | { 16 | return EvaluatorAccessPoint.DslConditionEvaluator != null 17 | && EvaluatorAccessPoint.DslConditionEvaluator.Evaluate(DslStatement, context); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/EvaluatorAccessPoint.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public static class EvaluatorAccessPoint 4 | { 5 | public static IDslConditionEvaluator DslConditionEvaluator { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/FuncCondition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public class FuncCondition : AbstractCondition 6 | { 7 | private Func condition; 8 | public FuncCondition(Func condition) 9 | { 10 | this.condition = condition; 11 | } 12 | 13 | public override bool Evaluate(object context) 14 | { 15 | return this.condition((T)context); 16 | } 17 | 18 | public override bool Evaluate(T context) 19 | { 20 | return this.condition(context); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/IDslConditionEvaluator.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public interface IDslConditionEvaluator 4 | { 5 | bool Evaluate(string condition, T context); 6 | } 7 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/Operation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | internal sealed class Operation 6 | { 7 | public static bool And(bool rule1Result, bool rule2Result) 8 | { 9 | return rule1Result && rule2Result; 10 | } 11 | 12 | public static bool Or(bool rule1Result, bool rule2Result) 13 | { 14 | return rule1Result || rule2Result; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/OperationRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | internal sealed class OperationRule : AbstractRule 6 | { 7 | private Func operation; 8 | private AbstractRule rule1; 9 | private AbstractRule rule2; 10 | 11 | public OperationRule(AbstractRule rule1, AbstractRule rule2, Func operation) 12 | { 13 | this.operation = operation; 14 | this.rule1 = rule1; 15 | this.rule2 = rule2; 16 | } 17 | 18 | public override bool Evaluate(T context) 19 | { 20 | return operation(rule1.Evaluate(context), rule2.Evaluate(context)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0a0f1cd2-7743-421e-b51b-5d3ca9890da1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Backup/RulesEngine/Rule.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class ConditionalRule : AbstractRule 4 | { 5 | private AbstractCondition condition; 6 | 7 | public ConditionalRule(AbstractCondition condition) 8 | { 9 | this.condition = condition; 10 | } 11 | 12 | public override bool Evaluate(T context) 13 | { 14 | return condition.Evaluate(context); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/RuleSet.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class RuleSet : AbstractRule 4 | { 5 | public override bool Evaluate(T context) 6 | { 7 | throw new System.NotImplementedException(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Backup/RulesEngine/RulesEngine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 9 | Library 10 | Properties 11 | RulesEngine 12 | RulesEngine 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 3.5 37 | 38 | 39 | 3.5 40 | 41 | 42 | 3.5 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /FluentFlow/ActivityProcessNode.cs: -------------------------------------------------------------------------------- 1 | using RulesEngine; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ActivityProcessNode : ProcessNode 6 | { 7 | private AbstractActivity activity; 8 | public ActivityProcessNode(AbstractActivity activity, FlowElement master) 9 | : base(master) 10 | { 11 | this.activity = activity; 12 | } 13 | 14 | internal override void Evaluate(T instance) 15 | { 16 | if (this.activity != null) activity.Execute(instance); 17 | base.Evaluate(instance); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /FluentFlow/ConditionDecisionNode.cs: -------------------------------------------------------------------------------- 1 | using RulesEngine; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ConditionDecisionNode : DecisionNode 6 | { 7 | private AbstractCondition condition; 8 | 9 | public ConditionDecisionNode(AbstractCondition condition, FlowElement master) 10 | : base(master) 11 | { 12 | this.condition = condition; 13 | } 14 | 15 | protected override bool Condition(T instance) 16 | { 17 | return condition.Evaluate(instance); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /FluentFlow/DecisionNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public abstract class DecisionNode : FlowElement 6 | { 7 | private TrueFalseNode trueNode; 8 | private FalseTrueNode falseNode; 9 | 10 | protected DecisionNode(FlowElement master) : base(master) 11 | { 12 | } 13 | 14 | public TrueFalseNode WhenTrue(Action> action) 15 | { 16 | trueNode = new TrueFalseNode(action, master); 17 | return trueNode; 18 | } 19 | 20 | public FalseTrueNode WhenFalse(Action> action) 21 | { 22 | falseNode = new FalseTrueNode(action, master); 23 | return falseNode; 24 | } 25 | 26 | protected abstract bool Condition(T instance); 27 | 28 | internal override void Evaluate(T instance) 29 | { 30 | var branchNode = trueNode ?? (falseNode ?? (DicisionBranchNode)null); 31 | if (branchNode == null) return; 32 | 33 | if(this.Condition(instance)) 34 | branchNode.Evaluate(instance); 35 | else 36 | branchNode.EvaluateOtherResult(instance); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /FluentFlow/Flow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public static class Flow 6 | { 7 | public static FlowNode For() 8 | { 9 | return new FlowNode(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /FluentFlow/FlowElement.cs: -------------------------------------------------------------------------------- 1 | namespace FluentFlow 2 | { 3 | public abstract class FlowElement 4 | { 5 | protected FlowElement master; 6 | 7 | protected FlowElement() 8 | { 9 | master = this; 10 | } 11 | 12 | protected FlowElement(FlowElement master) 13 | { 14 | this.master = master; 15 | } 16 | internal abstract void Evaluate(T instance); 17 | 18 | public virtual void Execute(T instance) 19 | { 20 | if(this.master != null) 21 | this.master.Evaluate(instance); 22 | else 23 | this.Evaluate(instance); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /FluentFlow/FlowNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RulesEngine; 3 | 4 | namespace FluentFlow 5 | { 6 | public class FlowNode : FlowElement 7 | { 8 | private DecisionNode decisionNode; 9 | private ProcessNode actionNode; 10 | 11 | public FlowNode() 12 | { 13 | } 14 | 15 | public FlowNode(FlowElement master): base(master) 16 | { 17 | } 18 | 19 | internal override void Evaluate(T instance) 20 | { 21 | if (decisionNode != null) decisionNode.Evaluate(instance); 22 | if (actionNode != null) actionNode.Evaluate(instance); 23 | } 24 | 25 | public DecisionNode Decide(Func func) 26 | { 27 | decisionNode = new ConditionDecisionNode(new FuncCondition(func), master); 28 | return decisionNode; 29 | } 30 | 31 | public DecisionNode Decide(TCondition condition) where TCondition : AbstractCondition 32 | { 33 | decisionNode = new ConditionDecisionNode(condition, master); 34 | return decisionNode; 35 | } 36 | 37 | public ProcessNode Do(Action> action) 38 | { 39 | actionNode = new FlowProcessNode(action, master); 40 | return actionNode; 41 | } 42 | 43 | public ProcessNode Do(Action action) 44 | { 45 | actionNode = new ActivityProcessNode(new ActionActivity(action), master); 46 | return actionNode; 47 | } 48 | 49 | public ProcessNode Do(AbstractActivity activity) 50 | { 51 | actionNode = new ActivityProcessNode(activity, master); 52 | return actionNode; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /FluentFlow/FlowProcessNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class FlowProcessNode : ProcessNode 6 | { 7 | private Action> action; 8 | public FlowProcessNode(Action> action, FlowElement master) 9 | : base(master) 10 | { 11 | this.action = action; 12 | } 13 | 14 | internal override void Evaluate(T instance) 15 | { 16 | if (action != null) 17 | { 18 | var flowNode = new FlowNode(master); 19 | action(flowNode); 20 | flowNode.Evaluate(instance); 21 | } 22 | base.Evaluate(instance); 23 | } 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /FluentFlow/FluentFlow.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {1EE600CA-741A-4968-933C-859787B8010C} 9 | Library 10 | Properties 11 | FluentFlow 12 | FluentFlow 13 | v3.5 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 3.5 42 | 43 | 44 | 3.5 45 | 46 | 47 | 3.5 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 67 | RulesEngine 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /FluentFlow/ProcessNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class ProcessNode : FlowElement 6 | { 7 | private Action> continuedAction; 8 | private Action finalAction; 9 | private FlowNode then; 10 | 11 | public ProcessNode(FlowElement master) : base(master) 12 | { 13 | } 14 | 15 | public FlowNode Then 16 | { 17 | get 18 | { 19 | if (then == null) then = new FlowNode(master); 20 | return then; 21 | } 22 | } 23 | 24 | internal override void Evaluate(T instance) 25 | { 26 | if (then != null) then.Evaluate(instance); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /FluentFlow/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FluentFlow")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FluentFlow")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c9a54f16-2a91-4408-8b48-ee5b63ab50df")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FluentFlow/TrueFalseNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FluentFlow 4 | { 5 | public class DicisionBranchNode : FlowProcessNode 6 | { 7 | protected ProcessNode onOtherResult; 8 | 9 | public DicisionBranchNode(Action> action, FlowElement master) 10 | : base(action, master) 11 | { 12 | } 13 | 14 | public void EvaluateOtherResult(T instance) 15 | { 16 | if(onOtherResult != null) onOtherResult.Evaluate(instance); 17 | } 18 | } 19 | 20 | public class TrueFalseNode : DicisionBranchNode 21 | { 22 | public TrueFalseNode(Action> action, FlowElement master) 23 | : base(action, master) 24 | { 25 | } 26 | 27 | public ProcessNode WhenFalse(Action> action) 28 | { 29 | onOtherResult = new FlowProcessNode(action, master); 30 | return onOtherResult; 31 | } 32 | } 33 | 34 | public class FalseTrueNode : DicisionBranchNode 35 | { 36 | public FalseTrueNode(Action> action, FlowElement master) 37 | : base(action, master) 38 | { 39 | } 40 | 41 | public ProcessNode WhenTrue(Action> action) 42 | { 43 | onOtherResult = new FlowProcessNode(action, master); 44 | return onOtherResult; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | RulesEngine - Define your business rules in boo DSL, Code in Flow Syntax 2 | ======================================================================== 3 | 4 | Rules engine allows you to define complex business rules in boo DSL as strings externally, outside of your source code, and execute them as part of your 5 | C# application. You can store rules in external text file / database, and change them without modifying your source code. 6 | 7 | You can pass in any a POCO object as context to the rules and use it evaluate the rule. See example below. 8 | 9 | Example: 10 | ------- 11 | 12 | Lets define rules on an Order class. 13 | 14 | public class Order 15 | { 16 | public double TotalPrice; 17 | public double Discount; 18 | } 19 | 20 | Your business rule can be if TotalPrice > 100, apply a discount of 10%. You can define both rule, and activity in boo DSL. 21 | 22 | var businessRule = "return (this.TotalPrice > 100)"; 23 | var businessAction = @"this.Discount = 10; return true;"; 24 | var condition = new DslCondition { DslStatement = statement }; 25 | var rule = new ActivityRule(condition, new DslActivity 26 | { 27 | DslStatement = businessAction 28 | }); 29 | rule.Evaluate(order); 30 | 31 | In above example, you can define business rule and actions externally in a file or database ( to track what rules executed on orders ). You can simply 32 | create an ActivityRule and pass condition and activity. 33 | 34 | You can also create complex rules like: 35 | 36 | var complexRule = (rule1 & rule2) | ( (rule3 | rule4) & (rule5 | rule6) ); 37 | complexRule.Evaluate(context); 38 | 39 | Rules Engine is designed such that it can easily be extended to other DSL evaluators such as boo. 40 | 41 | Rules Engine allows you to specify a Flow chart of your business requirement in easily understable syntax. The example below shows a sample flow. 42 | You can also use DSL conditions and activities as part of the flow. (The flow is a just a sample. It is not be a real business requirement :) ). 43 | 44 | var flow = Flow.For() 45 | .Do(a => 46 | a.Price = 10) 47 | .Then 48 | .Decide(o => o.Price > 10) 49 | .WhenTrue(a => a.Do(t => t.Price = 10) 50 | .Then 51 | .Decide(new DslCondition(condition)) 52 | .WhenTrue(b => b.Do(t => t.Price = 20)) 53 | .WhenFalse(b => b.Do(t => t.Price = 30)) 54 | ) 55 | .WhenFalse(a1 => a1.Do(t => t.Price = 30) 56 | .Then.Do(new DslActivity(activity)).Then.Do(t => t.Price = 50).Then 57 | .Decide(aa => aa.Price > 40).WhenFalse(a => a.Do(a2 => a2.Message ="test"))); 58 | 59 | var order = new Order { Price = 16 }; 60 | flow.Execute(order); 61 | 62 | -------------------------------------------------------------------------------- /RuleEngineTests/DslRuleTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RulesEngine; 3 | using RulesEngine.BooEvaluator; 4 | 5 | namespace RuleEngineTests 6 | { 7 | [TestFixture] 8 | public class DslRuleTests 9 | { 10 | private BooLangEvaluator evaluator; 11 | 12 | [SetUp] 13 | public void Setup() 14 | { 15 | var dslEngineStorage = new DslEngineStorage(); 16 | evaluator = new BooLangEvaluator(dslEngineStorage); 17 | } 18 | 19 | [Test] 20 | public void Can_Evaluate_Dsl_Expression() 21 | { 22 | var rule = "return (this.Price > 20 or this.Price < 15)"; 23 | var order = new Order { Price = 10, Message = "Soemthing" }; 24 | var result = evaluator.Evaluate(rule, order); 25 | Assert.IsTrue(result); 26 | } 27 | 28 | [Test] 29 | public void Can_Evaluate_Expression_As_ConditionalRule() 30 | { 31 | var statement = "return (this.Price > 20 or this.Price < 15)"; 32 | var order = new Order { Price = 10, Message = "Soemthing" }; 33 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 34 | var condition = new DslCondition { DslStatement = statement }; 35 | var rule = new ConditionalRule(condition); 36 | Assert.IsTrue(rule.Evaluate(order)); 37 | } 38 | 39 | [Test] 40 | public void Can_Evaluate_Expression_As_ActionActivityRule() 41 | { 42 | var statement = "return (this.Price > 20 or this.Price < 15)"; 43 | var order = new Order { Price = 10, Message = "Soemthing" }; 44 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 45 | var condition = new DslCondition { DslStatement = statement }; 46 | var rule = new ActivityRule(condition, new ActionActivity(t => 47 | { 48 | t.Message = "amp"; 49 | })); 50 | Assert.IsTrue(rule.Evaluate(order)); 51 | Assert.AreEqual("amp", order.Message); 52 | } 53 | 54 | [Test] 55 | public void Can_Evaluate_Expression_With_DslActivity() 56 | { 57 | var statement = "return (this.Price > 20 or this.Price < 15)"; 58 | var order = new Order { Price = 10, Message = "Something" }; 59 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 60 | var condition = new DslCondition { DslStatement = statement }; 61 | var rule = new ActivityRule(condition, new DslActivity 62 | { 63 | DslStatement = @" 64 | this.Message = ""dsl""; 65 | return true;" 66 | }); 67 | Assert.IsTrue(rule.Evaluate(order)); 68 | Assert.AreEqual("dsl", order.Message); 69 | } 70 | 71 | [Test] 72 | public void Can_Evaluate_Expression_With_FuncCondition() 73 | { 74 | var order = new Order { Price = 10, Message = "Something" }; 75 | var condition = new FuncCondition(o => o.Price < 20); 76 | var rule = new ActivityRule(condition, new ActionActivity(t => 77 | { 78 | t.Message = "amp"; 79 | })); 80 | Assert.IsTrue(rule.Evaluate(order)); 81 | Assert.AreEqual("amp", order.Message); 82 | } 83 | } 84 | 85 | public class Order 86 | { 87 | public int Price; 88 | public string Message; 89 | } 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /RuleEngineTests/FlowTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentFlow; 3 | using NUnit.Framework; 4 | using RulesEngine; 5 | using RulesEngine.BooEvaluator; 6 | 7 | namespace RuleEngineTests 8 | { 9 | [TestFixture] 10 | public class FlowTests 11 | { 12 | private BooLangEvaluator evaluator; 13 | 14 | [SetUp] 15 | public void Setup() 16 | { 17 | var dslEngineStorage = new DslEngineStorage(); 18 | evaluator = new BooLangEvaluator(dslEngineStorage); 19 | } 20 | 21 | [Test] 22 | public void Can_Setup_Flow() 23 | { 24 | var flow = Flow.For() 25 | .Do(a => 26 | a.Price = 10) 27 | .Then 28 | .Decide(o => o.Price > 10) 29 | .WhenTrue(a => a.Do(t => t.Price = 10) 30 | .Then 31 | .Decide(aa => aa.Price > 15) 32 | .WhenTrue(b => b.Do(t => t.Price = 20)) 33 | .WhenFalse(b => b.Do(t => t.Price = 30)) 34 | ) 35 | .WhenFalse(a1 => a1.Do(t => t.Price = 30) 36 | .Then.Do(t => t.Price = 40).Then.Do(t => t.Price = 50).Then 37 | .Decide(aa => aa.Price > 40).WhenFalse(a => a.Do(a2 => a2.Message ="test"))); 38 | 39 | var order = new Order {Price = 15}; 40 | flow.Execute(order); 41 | Console.WriteLine(order.Price); 42 | Console.WriteLine(order.Message); 43 | } 44 | 45 | [Test] 46 | public void Can_Setup_Flow_With_Dsl_Conditions() 47 | { 48 | var statement = "return (this.Price > 15 and this.Price < 20)"; 49 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 50 | 51 | var flow = Flow.For() 52 | .Decide(new DslCondition(statement)) 53 | .WhenTrue(a => a.Do(o => o.Message = "true")) 54 | .WhenFalse(a => a.Do(o => o.Message = "false")); 55 | 56 | var order = new Order { Price = 16 }; 57 | flow.Execute(order); 58 | Assert.AreEqual("true", order.Message); 59 | order.Price = 21; 60 | flow.Execute(order); 61 | Assert.AreEqual("false", order.Message); 62 | } 63 | 64 | [Test] 65 | public void Can_Setup_Flow_With_Dsl_Conditions_And_DslActiviy() 66 | { 67 | var condition = "return (this.Price > 15 and this.Price < 20)"; 68 | var activity = @"this.Message = ""true""; return true; "; 69 | EvaluatorAccessPoint.DslConditionEvaluator = evaluator; 70 | 71 | var flow = Flow.For() 72 | .Decide(new DslCondition(condition)) 73 | .WhenTrue(a => a.Do(new DslActivity(activity))) 74 | .WhenFalse(a => a.Do(o => o.Message = "false")); 75 | 76 | var order = new Order { Price = 16 }; 77 | flow.Execute(order); 78 | Assert.AreEqual("true", order.Message); 79 | order.Price = 21; 80 | flow.Execute(order); 81 | Assert.AreEqual("false", order.Message); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /RuleEngineTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RuleEngineTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RuleEngineTests")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("40a065ff-52b7-4e05-a757-830ecafd4b7c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RuleEngineTests/RubyRuleTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using NUnit.Framework; 4 | using RulesEngine; 5 | using RulesEngine.BooEvaluator; 6 | using RulesEngine.IronRubyEvaluator; 7 | 8 | namespace RuleEngineTests 9 | { 10 | [TestFixture] 11 | public class RubyRuleTests 12 | { 13 | private IronRubyEvaluator evaluator; 14 | 15 | [SetUp] 16 | public void Setup() 17 | { 18 | evaluator = new IronRubyEvaluator(); 19 | } 20 | 21 | [Test] 22 | public void Can_Evaluate_Ruby_Expression() 23 | { 24 | var rule = "this.Price > 20 or this.Price < 15"; 25 | var order = new Order { Price = 10, Message = "Soemthing" }; 26 | var result = evaluator.Evaluate(rule, order); 27 | Assert.IsTrue(result); 28 | } 29 | 30 | [Test] 31 | public void Can_Evaluate_Ruby_Expression_Again() 32 | { 33 | var rule = "this.Price > 20 and this.Price < 15"; 34 | var order = new Order { Price = 10, Message = "Soemthing" }; 35 | var result = evaluator.Evaluate(rule, order); 36 | Assert.IsFalse(result); 37 | } 38 | 39 | [Test] 40 | public void Can_Evaluate_Ruby_Expression_On_CardInfo_Context() 41 | { 42 | var rule = "this.IsVisa"; 43 | var context = new CardInfo {IsVisa = true}; 44 | var result = evaluator.Evaluate(rule, context); 45 | Assert.IsTrue(result); 46 | 47 | context = new CardInfo { IsVisa = false }; 48 | result = evaluator.Evaluate(rule, context); 49 | Assert.IsFalse(result); 50 | } 51 | } 52 | 53 | public class CardInfo 54 | { 55 | public bool IsVisa; 56 | } 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /RuleEngineTests/RuleEngineTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {870370DF-A640-4188-BDDD-AB1CCE2A568E} 9 | Library 10 | Properties 11 | RuleEngineTests 12 | RuleEngineTests 13 | v4.0 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.dll 41 | 42 | 43 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.dll 44 | 45 | 46 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.Yaml.dll 47 | 48 | 49 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Dynamic.dll 50 | 51 | 52 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.dll 53 | 54 | 55 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.Metadata.dll 56 | 57 | 58 | False 59 | ..\SharedLibs\nunit.framework.dll 60 | 61 | 62 | False 63 | ..\SharedLibs\Rhino.DSL.dll 64 | 65 | 66 | 67 | 3.5 68 | 69 | 70 | 3.5 71 | 72 | 73 | 3.5 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | {1EE600CA-741A-4968-933C-859787B8010C} 88 | FluentFlow 89 | 90 | 91 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1} 92 | RulesEngine.BooEvaluator 93 | 94 | 95 | {6CD480C0-8459-4C81-8A11-BD63546A8F33} 96 | RulesEngine.IronRubyEvaluator 97 | 98 | 99 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 100 | RulesEngine 101 | 102 | 103 | 104 | 105 | 106 | 107 | 114 | -------------------------------------------------------------------------------- /RuleEngineTests/RuleTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RulesEngine; 3 | 4 | namespace RuleEngineTests 5 | { 6 | [TestFixture] 7 | public class RuleTests 8 | { 9 | [Test] 10 | public void Can_Add_Rules() 11 | { 12 | var rule1 = new ConditionalRule(new FuncCondition(t => true)); 13 | var rule2 = new ConditionalRule(new FuncCondition(t => false)); 14 | 15 | var rule = rule1 & rule2; 16 | Assert.IsFalse(rule.Evaluate(10)); 17 | } 18 | 19 | [Test] 20 | public void Can_Or_Rules() 21 | { 22 | var rule1 = new ConditionalRule(new FuncCondition(t => true)); 23 | var rule2 = new ConditionalRule(new FuncCondition(t => false)); 24 | 25 | var rule = rule1 | rule2; 26 | Assert.IsTrue(rule.Evaluate(10)); 27 | } 28 | 29 | [Test] 30 | public void Can_Do_Complex_Rule() 31 | { 32 | var rule1 = new ConditionalRule(new FuncCondition(t => true)){ Name = "rule1" }; 33 | var rule2 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule2" }; 34 | var rule3 = new ConditionalRule(new FuncCondition(t => true)) { Name = "rule3" }; 35 | var rule4 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule4" }; 36 | var rule5 = new ConditionalRule(new FuncCondition(t => true)) { Name = "rule5" }; 37 | var rule6 = new ConditionalRule(new FuncCondition(t => false)) { Name = "rule6" }; 38 | 39 | var rule = (rule1 & rule2) | ( (rule3 | rule4) & (rule5 | rule6) ); 40 | Assert.IsTrue(rule.Evaluate(10)); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /RuleEngineTests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/BooLangEvaluator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Rhino.DSL; 4 | 5 | namespace RulesEngine.BooEvaluator 6 | { 7 | public class BooLangEvaluator : IDslConditionEvaluator 8 | { 9 | private Dictionary parsedModels; 10 | private RuleDslEngine ruleDslEngine; 11 | private DslFactory dslFactory; 12 | private IRuleDslEngineStorage dslEngineStorage; 13 | 14 | public BooLangEvaluator(IRuleDslEngineStorage dslEngineStorage) 15 | { 16 | parsedModels = new Dictionary(); 17 | ruleDslEngine = new RuleDslEngine(); 18 | ruleDslEngine.Storage = dslEngineStorage; 19 | dslFactory = new DslFactory(); 20 | dslFactory.Register(ruleDslEngine); 21 | this.dslEngineStorage = dslEngineStorage; 22 | } 23 | 24 | public bool Evaluate(string condition, T context) 25 | { 26 | EvaluationContext.CurrentContext = context; 27 | DslModel model = null; 28 | if (!parsedModels.ContainsKey(condition)) 29 | { 30 | model = CreateRuleModelFor(condition); 31 | parsedModels.Add(condition, model); 32 | } 33 | else 34 | { 35 | model = parsedModels[condition]; 36 | } 37 | return model.Evaluate(); 38 | } 39 | 40 | private DslModel CreateRuleModelFor(string condition) 41 | { 42 | DslModel model = null; 43 | lock(dslFactory) 44 | { 45 | var wrapperRule = String.Format(@" 46 | evaluate: 47 | {0} 48 | ", condition); 49 | var url = dslEngineStorage.AddCondition(wrapperRule); 50 | model = dslFactory.TryCreate(url); 51 | model.Initialize(); 52 | } 53 | return model; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/DslEngineStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Boo.Lang.Compiler.IO; 4 | using Rhino.DSL; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public class DslEngineStorage : IRuleDslEngineStorage 9 | { 10 | private string condition; 11 | 12 | public string AddCondition(string condition) 13 | { 14 | this.condition = condition; 15 | return typeof(RuleDslModel).Name; 16 | } 17 | 18 | public Boo.Lang.Compiler.ICompilerInput CreateInput(string url) 19 | { 20 | return new StringInput(url, condition); 21 | } 22 | 23 | public string GetChecksumForUrls(System.Type dslEngineType, System.Collections.Generic.IEnumerable urls) 24 | { 25 | return typeof(RuleDslModel).Name + "_" + dslEngineType.Name; 26 | } 27 | 28 | public string[] GetMatchingUrlsIn(string parentPath, ref string url) 29 | { 30 | return new [] { url }; 31 | } 32 | 33 | public string GetTypeNameFromUrl(string url) 34 | { 35 | return typeof(RuleDslModel).Name; 36 | } 37 | 38 | public bool IsUrlIncludeIn(string[] urls, string parentPath, string url) 39 | { 40 | return Array.IndexOf(urls, url) >= 0; 41 | } 42 | 43 | public bool IsValidScriptUrl(string url) 44 | { 45 | return true; 46 | } 47 | 48 | public void NotifyOnChange(System.Collections.Generic.IEnumerable urls, System.Action action) 49 | { 50 | 51 | } 52 | 53 | public void Dispose() 54 | { 55 | 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/DslModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Boo.Lang; 3 | using Boo.Lang.Compiler; 4 | using Boo.Lang.Compiler.Ast; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public abstract class DslModel 9 | { 10 | private Func evaluation; 11 | 12 | public DslModel() 13 | {} 14 | 15 | public abstract void Prepare(); 16 | 17 | public void Initialize() 18 | { 19 | Prepare(); 20 | } 21 | 22 | [Meta] 23 | public static Expression evaluate(BlockExpression formula) 24 | { 25 | var body = new Block(formula.LexicalInfo); 26 | for (int i = 0; i < formula.Body.Statements.Count; ++i) 27 | { 28 | var statement = formula.Body.Statements[i]; 29 | 30 | if (statement is ExpressionStatement && 31 | i == formula.Body.Statements.Count - 1) 32 | { 33 | var last = (ExpressionStatement)statement; 34 | body.Statements.Add(new ReturnStatement(last.Expression)); 35 | } 36 | else 37 | body.Statements.Add(formula.Body.Statements[i]); 38 | } 39 | 40 | var result = new BlockExpression(body); 41 | result.Parameters.Add(new ParameterDeclaration("this", 42 | CompilerContext.Current.CodeBuilder 43 | .CreateTypeReference(EvaluationContext.CurrentContext.GetType()))); 44 | result.ReturnType = CompilerContext.Current.CodeBuilder 45 | .CreateTypeReference(typeof(bool)); 46 | 47 | return new MethodInvocationExpression( 48 | new ReferenceExpression("SetEvaluationFunction"), result); 49 | } 50 | 51 | protected void SetEvaluationFunction(Func evaluation) 52 | { 53 | this.evaluation = evaluation; 54 | } 55 | 56 | public bool Evaluate() 57 | { 58 | return this.evaluation(EvaluationContext.CurrentContext); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/EvaluationContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RulesEngine.BooEvaluator 4 | { 5 | public static class EvaluationContext 6 | { 7 | public static object CurrentContext { get; set;} 8 | } 9 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/IRuleDslEngineStorage.cs: -------------------------------------------------------------------------------- 1 | using Rhino.DSL; 2 | 3 | namespace RulesEngine.BooEvaluator 4 | { 5 | public interface IRuleDslEngineStorage : IDslEngineStorage 6 | { 7 | string AddCondition(string condition); 8 | } 9 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.BooEvaluator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine.BooEvaluator")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2973bddf-cbd6-4bfc-ac32-0a0174a44d41")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/RuleDslEngine.cs: -------------------------------------------------------------------------------- 1 | using Boo.Lang.Compiler; 2 | using Boo.Lang.Compiler.IO; 3 | using Boo.Lang.Compiler.Pipelines; 4 | using Rhino.DSL; 5 | 6 | namespace RulesEngine.BooEvaluator 7 | { 8 | public class RuleDslEngine : DslEngine where M : DslModel 9 | { 10 | public override CompilerContext ForceCompile(string[] urls, string cacheFileName) 11 | { 12 | var booCompiler = new BooCompiler(); 13 | booCompiler.Parameters.OutputType = CompilerOutputType; 14 | booCompiler.Parameters.GenerateInMemory = true; 15 | booCompiler.Parameters.Pipeline = new CompileToMemory(); 16 | CustomizeCompiler(booCompiler, booCompiler.Parameters.Pipeline, new string[]{}); 17 | AddInputs(urls, booCompiler); 18 | var compilerContext = booCompiler.Run(); 19 | CompileCompleted(compilerContext); 20 | return compilerContext; 21 | } 22 | 23 | protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls) 24 | { 25 | compiler.Parameters.AddAssembly(typeof(BooCompiler).Assembly); 26 | compiler.Parameters.Ducky = true; 27 | pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof (M), "Prepare")); 28 | base.CustomizeCompiler(compiler, pipeline, urls); 29 | } 30 | 31 | private void AddInputs(string[] urls, BooCompiler compiler) 32 | { 33 | foreach (var url in urls) 34 | { 35 | compiler.Parameters.Input.Add(Storage.CreateInput(url)); 36 | } 37 | } 38 | 39 | private void CompileCompleted(CompilerContext context) 40 | { 41 | if(context.Errors.Count != 0) 42 | { 43 | throw CreateCompilerException(context); 44 | } 45 | HandleWarnings(context.Warnings); 46 | } 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/RuleDslModel.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine.BooEvaluator 2 | { 3 | public abstract class RuleDslModel : DslModel 4 | { 5 | public RuleDslModel() 6 | {} 7 | } 8 | } -------------------------------------------------------------------------------- /RulesEngine.BooEvaluator/RulesEngine.BooEvaluator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1} 9 | Library 10 | Properties 11 | RulesEngine.BooEvaluator 12 | RulesEngine.BooEvaluator 13 | v3.5 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | False 41 | ..\SharedLibs\Boo.Lang.dll 42 | 43 | 44 | False 45 | ..\SharedLibs\Boo.Lang.Compiler.dll 46 | 47 | 48 | False 49 | ..\SharedLibs\Boo.Lang.Parser.dll 50 | 51 | 52 | False 53 | ..\SharedLibs\Rhino.DSL.dll 54 | 55 | 56 | 57 | 3.5 58 | 59 | 60 | 3.5 61 | 62 | 63 | 3.5 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 81 | RulesEngine 82 | 83 | 84 | 85 | 92 | -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/IronRubyEvaluator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | 4 | namespace RulesEngine.IronRubyEvaluator 5 | { 6 | public class IronRubyEvaluator : IDslConditionEvaluator 7 | { 8 | public IronRubyEvaluator() 9 | { 10 | } 11 | 12 | public bool Evaluate(string condition, T context) 13 | { 14 | var ruleEngine = new RubyEngine(context.GetType(), condition); 15 | var rule = ruleEngine.Create(); 16 | return rule.Evaluate(context); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.IronRubyEvaluator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RulesEngine.IronRubyEvaluator")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9600ea41-d3a8-40b1-b853-d09aee8cd100")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/RubyClasses/RuleRuleFactory.rb: -------------------------------------------------------------------------------- 1 | include RulesEngine 2 | include RulesEngine::IronRubyEvaluator 3 | include $ruleAssembly$ 4 | 5 | class RuleRuleFactory 6 | 7 | def Create() 8 | internalCreate $contextType$, do |this| $condition$ end 9 | end 10 | 11 | def internalCreate(type, &condition) 12 | RubyRule.of(type).new condition 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/RubyEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Reflection; 6 | using IronRuby; 7 | using Microsoft.Scripting.Hosting; 8 | 9 | namespace RulesEngine.IronRubyEvaluator 10 | { 11 | public class RubyEngine 12 | { 13 | private readonly string dslFileName; 14 | private readonly List assemblies; 15 | private Type contextType; 16 | private string condition; 17 | private ScriptEngine engine; 18 | private ScriptSource source; 19 | 20 | public RubyEngine(Type type, string condition) 21 | { 22 | contextType = type; 23 | this.condition = condition; 24 | this.dslFileName = "RubyClasses\\RuleRuleFactory.rb"; 25 | this.assemblies = new List 26 | { 27 | typeof(AbstractRule).Assembly, 28 | typeof(RubyEngine).Assembly, 29 | type.Assembly 30 | }; 31 | } 32 | 33 | public ICondition Create() 34 | { 35 | this.engine = Ruby.CreateEngine(); 36 | var rubyRuleTemplate = String.Empty; 37 | using(var stream = new StreamReader(this.dslFileName)) 38 | { 39 | rubyRuleTemplate = stream.ReadToEnd(); 40 | } 41 | rubyRuleTemplate = rubyRuleTemplate.Replace("$ruleAssembly$", this.contextType.Namespace.Replace(".", "::")); 42 | rubyRuleTemplate = rubyRuleTemplate.Replace("$contextType$", this.contextType.Name); 43 | rubyRuleTemplate = rubyRuleTemplate.Replace("$condition$", this.condition); 44 | this.source = engine.CreateScriptSourceFromString(rubyRuleTemplate); 45 | 46 | var scope = engine.CreateScope(); 47 | assemblies.ForEach(a => engine.Runtime.LoadAssembly(a)); 48 | 49 | engine.Execute(source.GetCode(), scope); 50 | var @class = engine.Runtime.Globals.GetVariable("RuleRuleFactory"); 51 | 52 | var installer = engine.Operations.CreateInstance(@class); 53 | var rule = installer.Create(); 54 | 55 | return (ICondition) rule; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/RubyRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace RulesEngine.IronRubyEvaluator 7 | { 8 | public interface ICondition 9 | { 10 | bool Evaluate(object arg); 11 | } 12 | 13 | public class RubyRule : ICondition 14 | { 15 | private readonly Predicate evaluation; 16 | 17 | public RubyRule(Func evaluation) 18 | { 19 | this.evaluation = x => (x is Func) ? 20 | evaluation.Invoke(((Func)x).Invoke()) : 21 | (x is TContext) ? 22 | evaluation.Invoke((TContext)x) : false; 23 | } 24 | 25 | public bool Evaluate(object arg) 26 | { 27 | return evaluation(arg); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/RulesEngine.IronRubyEvaluator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {6CD480C0-8459-4C81-8A11-BD63546A8F33} 9 | Library 10 | Properties 11 | RulesEngine.IronRubyEvaluator 12 | RulesEngine.IronRubyEvaluator 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.dll 36 | 37 | 38 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.dll 39 | 40 | 41 | ..\packages\IronRuby.1.1.2\Lib\IronRuby.Libraries.Yaml.dll 42 | 43 | 44 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Dynamic.dll 45 | 46 | 47 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.dll 48 | 49 | 50 | ..\packages\IronRuby.1.1.2\Lib\Microsoft.Scripting.Metadata.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 69 | RulesEngine 70 | 71 | 72 | 73 | 74 | Designer 75 | 76 | 77 | Always 78 | 79 | 80 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /RulesEngine.IronRubyEvaluator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /RulesEngine.Persistence/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine.Persistence")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine.Persistence")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6dfbd04c-2f63-4ad1-871e-d75272acdd2f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RulesEngine.Persistence/RulesEngine.Persistence.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {0B37F672-A5CB-493B-AE58-F1529033D0D9} 9 | Library 10 | Properties 11 | RulesEngine.Persistence 12 | RulesEngine.Persistence 13 | v3.5 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | False 41 | ..\SharedLibs\Fluent\Castle.Core.dll 42 | 43 | 44 | False 45 | ..\SharedLibs\Fluent\Castle.DynamicProxy2.dll 46 | 47 | 48 | False 49 | ..\SharedLibs\Fluent\FluentNHibernate.dll 50 | 51 | 52 | False 53 | ..\SharedLibs\Fluent\NHibernate.dll 54 | 55 | 56 | False 57 | ..\SharedLibs\Fluent\NHibernate.ByteCode.Castle.dll 58 | 59 | 60 | 61 | 3.5 62 | 63 | 64 | 3.5 65 | 66 | 67 | 3.5 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 86 | -------------------------------------------------------------------------------- /RulesEngine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine", "RulesEngine\RulesEngine.csproj", "{05453C09-F3DB-46EF-851C-0AB0AC766955}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuleEngineTests", "RuleEngineTests\RuleEngineTests.csproj", "{870370DF-A640-4188-BDDD-AB1CCE2A568E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.BooEvaluator", "RulesEngine.BooEvaluator\RulesEngine.BooEvaluator.csproj", "{535D3A6C-9293-4CC6-8E44-76EEC136D0D1}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.Persistence", "RulesEngine.Persistence\RulesEngine.Persistence.csproj", "{0B37F672-A5CB-493B-AE58-F1529033D0D9}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentFlow", "FluentFlow\FluentFlow.csproj", "{1EE600CA-741A-4968-933C-859787B8010C}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesEngine.IronRubyEvaluator", "RulesEngine.IronRubyEvaluator\RulesEngine.IronRubyEvaluator.csproj", "{6CD480C0-8459-4C81-8A11-BD63546A8F33}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {05453C09-F3DB-46EF-851C-0AB0AC766955}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {870370DF-A640-4188-BDDD-AB1CCE2A568E}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {535D3A6C-9293-4CC6-8E44-76EEC136D0D1}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {0B37F672-A5CB-493B-AE58-F1529033D0D9}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {1EE600CA-741A-4968-933C-859787B8010C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {1EE600CA-741A-4968-933C-859787B8010C}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {1EE600CA-741A-4968-933C-859787B8010C}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {1EE600CA-741A-4968-933C-859787B8010C}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {6CD480C0-8459-4C81-8A11-BD63546A8F33}.Release|Any CPU.Build.0 = Release|Any CPU 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /RulesEngine/AbstractActivity.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public abstract class AbstractActivity 4 | { 5 | public abstract void Execute(object context); 6 | } 7 | 8 | public abstract class AbstractActivity : AbstractActivity 9 | { 10 | public abstract void Execute(T context); 11 | } 12 | } -------------------------------------------------------------------------------- /RulesEngine/AbstractCondition.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public abstract class AbstractCondition 4 | { 5 | public abstract bool Evaluate(object context); 6 | } 7 | 8 | public abstract class AbstractCondition : AbstractCondition 9 | { 10 | public abstract bool Evaluate(T context); 11 | } 12 | } -------------------------------------------------------------------------------- /RulesEngine/AbstractRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public abstract class AbstractRule 6 | { 7 | public abstract bool Evaluate(T context); 8 | public string Name { get; set; } 9 | 10 | 11 | public static AbstractRule operator &(AbstractRule rule1, AbstractRule rule2) 12 | { 13 | return new OperationRule(rule1, rule2, Operation.And); 14 | } 15 | 16 | public static AbstractRule operator |(AbstractRule rule1, AbstractRule rule2) 17 | { 18 | return new OperationRule(rule1, rule2, Operation.Or); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /RulesEngine/ActionActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public class ActionActivity : AbstractActivity 6 | { 7 | private Action action; 8 | 9 | public ActionActivity(Action action) 10 | { 11 | this.action = action; 12 | } 13 | 14 | public override void Execute(object context) 15 | { 16 | this.action((T) context); 17 | } 18 | 19 | public override void Execute(T context) 20 | { 21 | this.action(context); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /RulesEngine/ActivityRule.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class ActivityRule : ConditionalRule 4 | { 5 | private AbstractActivity activity; 6 | 7 | public ActivityRule(AbstractCondition condition, 8 | AbstractActivity activity) : base(condition) 9 | { 10 | this.activity = activity; 11 | } 12 | 13 | public override bool Evaluate(T context) 14 | { 15 | if(base.Evaluate(context)) 16 | { 17 | this.activity.Execute(context); 18 | return true; 19 | } 20 | return false; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /RulesEngine/DslActivity.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class DslActivity : AbstractActivity 4 | { 5 | public string DslStatement { get; set; } 6 | 7 | public DslActivity(){} 8 | 9 | public DslActivity(string statement) 10 | { 11 | this.DslStatement = statement; 12 | } 13 | 14 | public override void Execute(object context) 15 | { 16 | if(EvaluatorAccessPoint.DslConditionEvaluator != null) 17 | EvaluatorAccessPoint.DslConditionEvaluator.Evaluate(DslStatement, context); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /RulesEngine/DslCondition.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class DslCondition : AbstractCondition 4 | { 5 | public string DslStatement { get; set; } 6 | 7 | public DslCondition(){} 8 | 9 | public DslCondition(string statement) 10 | { 11 | this.DslStatement = statement; 12 | } 13 | 14 | public override bool Evaluate(object context) 15 | { 16 | return EvaluatorAccessPoint.DslConditionEvaluator != null 17 | && EvaluatorAccessPoint.DslConditionEvaluator.Evaluate(DslStatement, context); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /RulesEngine/EvaluatorAccessPoint.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public static class EvaluatorAccessPoint 4 | { 5 | public static IDslConditionEvaluator DslConditionEvaluator { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /RulesEngine/FuncCondition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | public class FuncCondition : AbstractCondition 6 | { 7 | private Func condition; 8 | public FuncCondition(Func condition) 9 | { 10 | this.condition = condition; 11 | } 12 | 13 | public override bool Evaluate(object context) 14 | { 15 | return this.condition((T)context); 16 | } 17 | 18 | public override bool Evaluate(T context) 19 | { 20 | return this.condition(context); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /RulesEngine/IDslConditionEvaluator.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public interface IDslConditionEvaluator 4 | { 5 | bool Evaluate(string condition, T context); 6 | } 7 | } -------------------------------------------------------------------------------- /RulesEngine/Operation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | internal sealed class Operation 6 | { 7 | public static bool And(bool rule1Result, bool rule2Result) 8 | { 9 | return rule1Result && rule2Result; 10 | } 11 | 12 | public static bool Or(bool rule1Result, bool rule2Result) 13 | { 14 | return rule1Result || rule2Result; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /RulesEngine/OperationRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RulesEngine 4 | { 5 | internal sealed class OperationRule : AbstractRule 6 | { 7 | private Func operation; 8 | private AbstractRule rule1; 9 | private AbstractRule rule2; 10 | 11 | public OperationRule(AbstractRule rule1, AbstractRule rule2, Func operation) 12 | { 13 | this.operation = operation; 14 | this.rule1 = rule1; 15 | this.rule2 = rule2; 16 | } 17 | 18 | public override bool Evaluate(T context) 19 | { 20 | return operation(rule1.Evaluate(context), rule2.Evaluate(context)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /RulesEngine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RulesEngine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RulesEngine")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0a0f1cd2-7743-421e-b51b-5d3ca9890da1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RulesEngine/Rule.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class ConditionalRule : AbstractRule 4 | { 5 | private AbstractCondition condition; 6 | 7 | public ConditionalRule(AbstractCondition condition) 8 | { 9 | this.condition = condition; 10 | } 11 | 12 | public override bool Evaluate(T context) 13 | { 14 | return condition.Evaluate(context); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /RulesEngine/RuleSet.cs: -------------------------------------------------------------------------------- 1 | namespace RulesEngine 2 | { 3 | public class RuleSet : AbstractRule 4 | { 5 | public override bool Evaluate(T context) 6 | { 7 | throw new System.NotImplementedException(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /RulesEngine/RulesEngine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {05453C09-F3DB-46EF-851C-0AB0AC766955} 9 | Library 10 | Properties 11 | RulesEngine 12 | RulesEngine 13 | v3.5 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 3.5 42 | 43 | 44 | 3.5 45 | 46 | 47 | 3.5 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 77 | -------------------------------------------------------------------------------- /SharedLibs/Boo.Lang.Compiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Boo.Lang.Compiler.dll -------------------------------------------------------------------------------- /SharedLibs/Boo.Lang.Parser.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Boo.Lang.Parser.dll -------------------------------------------------------------------------------- /SharedLibs/Boo.Lang.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Boo.Lang.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/Antlr3.Runtime.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/Antlr3.Runtime.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/Castle.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/Castle.Core.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/Castle.DynamicProxy2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/Castle.DynamicProxy2.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/FluentNHibernate.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/FluentNHibernate.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/Iesi.Collections.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/Iesi.Collections.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/NHibernate.ByteCode.Castle.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/NHibernate.ByteCode.Castle.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/NHibernate.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/NHibernate.dll -------------------------------------------------------------------------------- /SharedLibs/Fluent/log4net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Fluent/log4net.dll -------------------------------------------------------------------------------- /SharedLibs/Rhino.DSL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/Rhino.DSL.dll -------------------------------------------------------------------------------- /SharedLibs/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/SharedLibs/nunit.framework.dll -------------------------------------------------------------------------------- /UpgradeLog.XML: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport.css: -------------------------------------------------------------------------------- 1 | BODY 2 | { 3 | BACKGROUND-COLOR: white; 4 | FONT-FAMILY: "Verdana", sans-serif; 5 | FONT-SIZE: 100%; 6 | MARGIN-LEFT: 0px; 7 | MARGIN-TOP: 0px 8 | } 9 | P 10 | { 11 | FONT-FAMILY: "Verdana", sans-serif; 12 | FONT-SIZE: 70%; 13 | LINE-HEIGHT: 12pt; 14 | MARGIN-BOTTOM: 0px; 15 | MARGIN-LEFT: 10px; 16 | MARGIN-TOP: 10px 17 | } 18 | .note 19 | { 20 | BACKGROUND-COLOR: #ffffff; 21 | COLOR: #336699; 22 | FONT-FAMILY: "Verdana", sans-serif; 23 | FONT-SIZE: 100%; 24 | MARGIN-BOTTOM: 0px; 25 | MARGIN-LEFT: 0px; 26 | MARGIN-TOP: 0px; 27 | PADDING-RIGHT: 10px 28 | } 29 | .infotable 30 | { 31 | BACKGROUND-COLOR: #f0f0e0; 32 | BORDER-BOTTOM: #ffffff 0px solid; 33 | BORDER-COLLAPSE: collapse; 34 | BORDER-LEFT: #ffffff 0px solid; 35 | BORDER-RIGHT: #ffffff 0px solid; 36 | BORDER-TOP: #ffffff 0px solid; 37 | FONT-SIZE: 70%; 38 | MARGIN-LEFT: 10px 39 | } 40 | .issuetable 41 | { 42 | BACKGROUND-COLOR: #ffffe8; 43 | BORDER-COLLAPSE: collapse; 44 | COLOR: #000000; 45 | FONT-SIZE: 100%; 46 | MARGIN-BOTTOM: 10px; 47 | MARGIN-LEFT: 13px; 48 | MARGIN-TOP: 0px 49 | } 50 | .issuetitle 51 | { 52 | BACKGROUND-COLOR: #ffffff; 53 | BORDER-BOTTOM: #dcdcdc 1px solid; 54 | BORDER-TOP: #dcdcdc 1px; 55 | COLOR: #003366; 56 | FONT-WEIGHT: normal 57 | } 58 | .header 59 | { 60 | BACKGROUND-COLOR: #cecf9c; 61 | BORDER-BOTTOM: #ffffff 1px solid; 62 | BORDER-LEFT: #ffffff 1px solid; 63 | BORDER-RIGHT: #ffffff 1px solid; 64 | BORDER-TOP: #ffffff 1px solid; 65 | COLOR: #000000; 66 | FONT-WEIGHT: bold 67 | } 68 | .issuehdr 69 | { 70 | BACKGROUND-COLOR: #E0EBF5; 71 | BORDER-BOTTOM: #dcdcdc 1px solid; 72 | BORDER-TOP: #dcdcdc 1px solid; 73 | COLOR: #000000; 74 | FONT-WEIGHT: normal 75 | } 76 | .issuenone 77 | { 78 | BACKGROUND-COLOR: #ffffff; 79 | BORDER-BOTTOM: 0px; 80 | BORDER-LEFT: 0px; 81 | BORDER-RIGHT: 0px; 82 | BORDER-TOP: 0px; 83 | COLOR: #000000; 84 | FONT-WEIGHT: normal 85 | } 86 | .content 87 | { 88 | BACKGROUND-COLOR: #e7e7ce; 89 | BORDER-BOTTOM: #ffffff 1px solid; 90 | BORDER-LEFT: #ffffff 1px solid; 91 | BORDER-RIGHT: #ffffff 1px solid; 92 | BORDER-TOP: #ffffff 1px solid; 93 | PADDING-LEFT: 3px 94 | } 95 | .issuecontent 96 | { 97 | BACKGROUND-COLOR: #ffffff; 98 | BORDER-BOTTOM: #dcdcdc 1px solid; 99 | BORDER-TOP: #dcdcdc 1px solid; 100 | PADDING-LEFT: 3px 101 | } 102 | A:link 103 | { 104 | COLOR: #cc6633; 105 | TEXT-DECORATION: underline 106 | } 107 | A:visited 108 | { 109 | COLOR: #cc6633; 110 | } 111 | A:active 112 | { 113 | COLOR: #cc6633; 114 | } 115 | A:hover 116 | { 117 | COLOR: #cc3300; 118 | TEXT-DECORATION: underline 119 | } 120 | H1 121 | { 122 | BACKGROUND-COLOR: #003366; 123 | BORDER-BOTTOM: #336699 6px solid; 124 | COLOR: #ffffff; 125 | FONT-SIZE: 130%; 126 | FONT-WEIGHT: normal; 127 | MARGIN: 0em 0em 0em -20px; 128 | PADDING-BOTTOM: 8px; 129 | PADDING-LEFT: 30px; 130 | PADDING-TOP: 16px 131 | } 132 | H2 133 | { 134 | COLOR: #000000; 135 | FONT-SIZE: 80%; 136 | FONT-WEIGHT: bold; 137 | MARGIN-BOTTOM: 3px; 138 | MARGIN-LEFT: 10px; 139 | MARGIN-TOP: 20px; 140 | PADDING-LEFT: 0px 141 | } 142 | H3 143 | { 144 | COLOR: #000000; 145 | FONT-SIZE: 80%; 146 | FONT-WEIGHT: bold; 147 | MARGIN-BOTTOM: -5px; 148 | MARGIN-LEFT: 10px; 149 | MARGIN-TOP: 20px 150 | } 151 | H4 152 | { 153 | COLOR: #000000; 154 | FONT-SIZE: 70%; 155 | FONT-WEIGHT: bold; 156 | MARGIN-BOTTOM: 0px; 157 | MARGIN-TOP: 15px; 158 | PADDING-BOTTOM: 0px 159 | } 160 | UL 161 | { 162 | COLOR: #000000; 163 | FONT-SIZE: 70%; 164 | LIST-STYLE: square; 165 | MARGIN-BOTTOM: 0pt; 166 | MARGIN-TOP: 0pt 167 | } 168 | OL 169 | { 170 | COLOR: #000000; 171 | FONT-SIZE: 70%; 172 | LIST-STYLE: square; 173 | MARGIN-BOTTOM: 0pt; 174 | MARGIN-TOP: 0pt 175 | } 176 | LI 177 | { 178 | LIST-STYLE: square; 179 | MARGIN-LEFT: 0px 180 | } 181 | .expandable 182 | { 183 | CURSOR: hand 184 | } 185 | .expanded 186 | { 187 | color: black 188 | } 189 | .collapsed 190 | { 191 | DISPLAY: none 192 | } 193 | .foot 194 | { 195 | BACKGROUND-COLOR: #ffffff; 196 | BORDER-BOTTOM: #cecf9c 1px solid; 197 | BORDER-TOP: #cecf9c 2px solid 198 | } 199 | .settings 200 | { 201 | MARGIN-LEFT: 25PX; 202 | } 203 | .help 204 | { 205 | TEXT-ALIGN: right; 206 | margin-right: 10px; 207 | } 208 | -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport.xslt: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |

63 | Solution: 64 | Project: 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |

73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 102 | 103 | 104 | 105 | 106 | 107 | src 108 | 109 | 126 | 127 | 128 | 129 | 130 | 131 | 139 | 143 | 144 | 145 | 146 |
FilenameStatusErrorsWarnings
90 | javascript:document.images[''].click()src 91 | 93 | 94 | 95 | Converted 96 | 97 | 98 | 99 | Converted 100 | 101 |
132 | 133 | files 134 | 135 | 136 | 1 file 137 | 138 | 140 | Converted:
141 | Not converted: 142 |
147 |
148 |
149 | 150 | 151 | 152 | : 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | Conversion Report 162 | <xsl:if test="Properties/Property[@Name='LogNumber']"> 163 | <xsl:value-of select="Properties/Property[@Name='LogNumber']/@Value"/> 164 | </xsl:if> 165 | 166 | 189 | 190 | 191 |

Conversion Report -

192 | 193 |

194 | Time of Conversion:
195 |

196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 |

221 | 222 | 223 | 226 | 227 | 228 |
224 | Conversion Settings 225 |

229 | 230 | 231 |
232 |
233 | -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport_Minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/_UpgradeReport_Files/UpgradeReport_Minus.gif -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport_Plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/_UpgradeReport_Files/UpgradeReport_Plus.gif -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/IronRuby.1.1.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/IronRuby.1.1.2.nupkg -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/IronRuby.Libraries.Yaml.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/IronRuby.Libraries.Yaml.dll -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/IronRuby.Libraries.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/IronRuby.Libraries.dll -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/IronRuby.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/IronRuby.dll -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/Microsoft.Dynamic.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/Microsoft.Dynamic.dll -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/Microsoft.Scripting.Metadata.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/Microsoft.Scripting.Metadata.dll -------------------------------------------------------------------------------- /packages/IronRuby.1.1.2/Lib/Microsoft.Scripting.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nara/RulesEngine/39a840d186e6a556cd5e8b05a907acc75072f972/packages/IronRuby.1.1.2/Lib/Microsoft.Scripting.dll -------------------------------------------------------------------------------- /packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | --------------------------------------------------------------------------------