コード例 #1
0
        public void should_throw_for_unrecognized_params()
        {
            var ruleEngine = new ConditionEvaluator();

            Assert.Throws<UnrecognizedParameterException>(() =>
            {
                var condition = "Age > 10 OR NotExistParam == 5";
                ruleEngine.Evaluate(condition, new Person
                {
                    Age = 10
                });
            });
        }
コード例 #2
0
ファイル: PromotionModule.cs プロジェクト: Kooboo/Ecommerce
        public PromotionModule(
            PromotionService promotionService,
            IPromotionPolicyProvider policyFactory,
            ConditionEvaluator ruleEngine)
        {
            Require.NotNull(promotionService, "promotionService");
            Require.NotNull(policyFactory, "policyFactory");
            Require.NotNull(ruleEngine, "ruleEngine");

            _promotionService = promotionService;
            _policyFactory = policyFactory;
            _ruleEngine = ruleEngine;
        }
コード例 #3
0
ファイル: IfElseRule.cs プロジェクト: Kooboo/Ecommerce
        public override IEnumerable<ConfiguredActivity> Execute(object dataContext)
        {
            var evaluator = new ConditionEvaluator();
            var success = evaluator.Evaluate(Conditions, dataContext);

            if (success)
            {
                return Further(Then, dataContext);
            }
            else
            {
                return Further(Else, dataContext);
            }
        }
コード例 #4
0
ファイル: PromotionMatcher.cs プロジェクト: Kooboo/Ecommerce
 public PromotionMatcher(ConditionEvaluator ruleEngine)
 {
     _ruleEngine = ruleEngine;
 }
コード例 #5
0
 private bool CheckCondition(string condition, object contextModel)
 {
     var ruleEngine = new ConditionEvaluator();
     return ruleEngine.Evaluate(condition, contextModel);
 }
コード例 #6
0
 public PromotionConditionChecker(ConditionEvaluator ruleEngine)
 {
     _ruleEngine = ruleEngine;
 }