public override int GetHashCode() { unchecked { var hashCode = (TagPattern != null ? TagPattern.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UrlTemplate != null ? UrlTemplate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ResolvedTagPattern != null ? ResolvedTagPattern.GetHashCode() : 0); return(hashCode); } }
public void CheckConfiguration() { FixEmptyContainers(); if (string.IsNullOrEmpty(TagPattern)) { throw new DeveroomConfigurationException("'traceability/tagLinks[]/tagPattern' must be specified"); } if (string.IsNullOrEmpty(UrlTemplate)) { throw new DeveroomConfigurationException("'traceability/tagLinks[]/urlTemplate' must be specified"); } try { ResolvedTagPattern = new Regex("^" + TagPattern.TrimStart('^').TrimEnd('$') + "$"); } catch (Exception e) { throw new DeveroomConfigurationException($"Invalid regular expression '{TagPattern}' was specified as 'traceability/tagLinks[]/tagPattern': {e.Message}"); } }
private void Search() { Matches.Clear(); IEnumerable <TodoViewModel> results = AllEntries; string expression = Text.ToLower(); foreach (var match in StatusPattern.Matches(expression).OfType <Match>().OrderByDescending(x => x.Index)) { string statusName = match.Groups[1].Value; bool status = new[] { "done", "close", "closed" }.Contains(statusName); results = results.Where(r => r.Model.Done == status); expression = expression.Remove(match.Index, match.Length); } foreach (var match in TagPattern.Matches(expression).OfType <Match>().OrderByDescending(x => x.Index)) { string tagName = match.Groups[1].Value; if (string.IsNullOrWhiteSpace(tagName)) { tagName = match.Groups[2].Value; } if (string.IsNullOrWhiteSpace(tagName)) { continue; } results = results.Where(r => r.Tags.Any(t => t.Model.Name.Equals(tagName, StringComparison.OrdinalIgnoreCase))); expression = expression.Remove(match.Index, match.Length); } foreach (var match in DetailsPattern.Matches(expression).OfType <Match>().OrderByDescending(x => x.Index)) { string searchText = match.Groups[1].Value; if (string.IsNullOrWhiteSpace(searchText)) { searchText = match.Groups[2].Value; } if (string.IsNullOrWhiteSpace(searchText)) { continue; } results = results.Where(r => (r.Model.Details ?? string.Empty).ToLower().Contains(searchText)); expression = expression.Remove(match.Index, match.Length); } expression = expression.Trim(); if (!string.IsNullOrWhiteSpace(expression)) { results = results.Where(t => t.Model.Summary.ToLower().Contains(expression)); } foreach (var entry in results) { Matches.Add(entry); } }