protected virtual bool MatchItemEquals(T item, FilterPart part) { if (item?.FilterString == null) { return(false); } var ret = item.FilterString.Equals(part.FilterString, StringComparison.OrdinalIgnoreCase); return(part.Negate ? !ret : ret); }
protected override bool MatchItemStartsWith(MenuCommandBoundItem item, FilterPart part) { var shortcut = false; if (FilterParts.Count == 1 && part.FilterString.Length > 1) { var strings = part.FilterString.ToUpper().Select(c => c.ToString()); var pattern = string.Join(".*", strings); shortcut = Regex.IsMatch(item.PathFilterString, pattern, RegexOptions.None); } return(shortcut || base.MatchItemStartsWith(item, part)); }
protected virtual bool MatchItemContaining(T item, FilterPart part) { if (item?.FilterString == null) { return(false); } if (part.Negate) { return(item.FilterString.IndexOf(part.FilterString, StringComparison.OrdinalIgnoreCase) == -1); } return(item.FilterString.IndexOf(part.FilterString, StringComparison.OrdinalIgnoreCase) != -1); }
protected virtual bool MatchItemStartsWith(T item, FilterPart part) { if (item?.FilterString == null) { return(false); } if (FilterParts.Count == 0) { return(true); } var ret = item.FilterString.StartsWith(FilterParts.First().FilterString, StringComparison.OrdinalIgnoreCase); return(part.Negate ? !ret : ret); }