コード例 #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());
 }