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); }
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); }
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); }
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(); } }
public abstract bool Match <T>(T item, List <PropertyInfo> props, FilterOption options);
public override bool Match <T>(T item, List <PropertyInfo> props, FilterOption options) { return(!_filter.Match(item, props, options)); }