Пример #1
0
        private static RuleCriteriaValue CreateCriteriaValue(RuleCriteriaValueDto dto)
        {
            var criteriaDefinition = DefinedCriteriaDefinitions.All.FirstOrDefault(x => x.Name == dto.Name);
            var operatorObj        = GetOperator(dto.Operator);

            return(new RuleCriteriaValue(dto.Value as Value, operatorObj, criteriaDefinition));
        }
Пример #2
0
        private static void ChangeCriteriaDefinition(RuleCriteriaValueDto criteria)
        {
            var criteriaDefinition  = GetFirstBestMatchedCriteriaDef(criteria);
            var criteriaDefOperator = criteriaDefinition.Type.Operators.First();

            criteria.Name = criteriaDefinition.Name;
            if (criteria.Operator.Type != criteriaDefOperator.Type)
            {
                criteria.Operator = criteriaDefOperator.ToDto();
                criteria.Value    = criteriaDefOperator.DefaultValue;
            }
        }
Пример #3
0
 private static CriteriaDefinition GetFirstBestMatchedCriteriaDef(RuleCriteriaValueDto criteria)
 {
     return(DefinedCriteriaDefinitions.All.FirstOrDefault(x => x.Type.Name == criteria.Operator.Type) ??
            DefinedCriteriaDefinitions.All.First());
 }