예제 #1
0
파일: TextFilter.cs 프로젝트: sg1019/Filter
        public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options)
        {
            if (options is null)
            {
                options = new FilterOption();
            }

            foreach (var prop in props)
            {
                var propValue = prop.GetValue(item);

                if (propValue is null || !(propValue is string))
                {
                    continue;
                }

                var value        = (string)propValue;
                var compareValue = _text;
                if (options.TrimBeforeComparison)
                {
                    value        = value.Trim();
                    compareValue = compareValue.Trim();
                }

                if (string.Equals(value, compareValue, options.StrComparison))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options)
        {
            foreach (var prop in props)
            {
                var propValue = prop.GetValue(item);

                if (propValue is null || !(propValue is TInterval))
                {
                    continue;
                }

                var lowerComparison = _lowerBound.CompareTo(propValue);
                if (lowerComparison > 0)
                {
                    continue;
                }
                if (_lowerOpened && lowerComparison == 0)
                {
                    continue;
                }

                var upperComparison = _upperBound.CompareTo(propValue);
                if (upperComparison < 0)
                {
                    continue;
                }
                if (_upperOpened && upperComparison == 0)
                {
                    continue;
                }
                return(true);
            }
            return(false);
        }
예제 #3
0
        public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options)
        {
            if (options == null)
            {
                options = new FilterOption();
            }

            foreach (var prop in props)
            {
                var propValue = prop.GetValue(item);

                if (propValue is null || !(propValue is double))
                {
                    continue;
                }
                var value = (double)propValue;
                switch (_comparator)
                {
                case Comparator.LessThan:
                    if (value < _value)
                    {
                        return(true);
                    }
                    break;

                case Comparator.LessOrEqual:
                    if (value <= _value + options.DoubleComparisonPrecision)
                    {
                        return(true);
                    }
                    break;

                case Comparator.GreaterThan:
                    if (value > _value)
                    {
                        return(true);
                    }
                    break;

                case Comparator.GreaterOrEqual:
                    if (value >= _value - options.DoubleComparisonPrecision)
                    {
                        return(true);
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            return(false);
        }
예제 #4
0
        public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options)
        {
            switch (_op)
            {
            case Operator.And:
                return(_left.Match(item, props, options) && _right.Match(item, props, options));

            case Operator.Or:
                return(_left.Match(item, props, options) || _right.Match(item, props, options));

            default:
                throw new NotImplementedException();
            }
        }
예제 #5
0
파일: FIlter.cs 프로젝트: sg1019/Filter
 public abstract bool Match <T>(T item, List <PropertyInfo> props, FilterOption options);
예제 #6
0
 public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options)
 {
     return(!_filter.Match(item, props, options));
 }