Beispiel #1
0
        public void LoadRules()
        {
            //Assuming there is only one rule in this example
            var rule = BuildRule();

            _ruleSet.Add(new[] { rule });
        }
Beispiel #2
0
        public IEnumerable <IRuleSet> GetRuleSets()
        {
            var rules = new RuleRepository().GetRules();

            _ruleSet.Add(rules.Select(BuildRule).ToArray());

            return(new [] { _ruleSet });
        }
Beispiel #3
0
 public void LoadRules()
 {
     _ruleSet.Add(new []
     {
         BuildJohnDoLargeOrderRule(),
         BuildMultipleOrdersRule(),
         BuildImportantCustomerRule(),
     });
 }
Beispiel #4
0
 public void LoadRules()
 {
     _ruleSet.Add(new[]
     {
         SrCitizenEligibility(),
         ChildCOnessionEligibility(),
         ValidateSrCitizenFlag(),
     });
 }
        public void AddRule(RuleDefinition definition)
        {
            var builder = new RuleBuilder();

            builder.Name(definition.Name);
            foreach (var condition in definition.Conditions)
            {
                ParsePattern(builder, condition);
            }
            foreach (var action in definition.Actions)
            {
                var param = action.Parameters.FirstOrDefault();
                var obj   = GetObject(param.Type);
                builder.RightHandSide().Action(ParseAction(obj, action, param.Name));
            }
            _ruleSet.Add(new[] { builder.Build() });
        }
Beispiel #6
0
        public void AddRule(RuleDefinition definition)
        {
            RuleBuilder builder = new RuleBuilder();

            builder.Name(definition.Name);
            definition.Conditions.ForEach(o =>
            {
                ParameterExpression parameter = o.Parameters.FirstOrDefault();
                Type type = parameter.Type;
                PatternBuilder customerPattern = builder.LeftHandSide().Pattern(type, parameter.Name);
                customerPattern.Condition(o);
            });
            definition.Actions.ForEach(o =>
            {
                ParameterExpression param = o.Parameters.FirstOrDefault();
                dynamic obj = getObject(param.Type);
                builder.RightHandSide().Action(parseAction(obj, o, param.Name));
            });
            _ruleSet.Add(new[] { builder.Build() });
        }
Beispiel #7
0
 /// <summary>
 /// Adds a rule to the rule set.
 /// </summary>
 /// <param name="ruleSet">Rule set instance.</param>
 /// <param name="ruleDefinition">Rule definition to add.</param>
 public static void Add(this IRuleSet ruleSet, IRuleDefinition ruleDefinition)
 {
     ruleSet.Add(Enumerable.Repeat(ruleDefinition, 1));
 }
 public void LoadRules <T>(RuleEngineRequestModel list)
 {
     _ruleSet.Add(
         BuildRule <T>(list)
         );
 }
        public void LoadRules()
        {
            var rule = BuildRule();

            _ruleSet.Add(new [] { rule });
        }