internal TemplateMatchResult IsStringMatch(string search, string strToSearch) { if (search == null || strToSearch == null) { return(new TemplateMatchResult()); } if (search.Equals(strToSearch, StringComparison.OrdinalIgnoreCase)) { return(new TemplateMatchResult { IsExactMatch = true, StartsWith = true }); } if (strToSearch.IndexOf(search, StringComparison.OrdinalIgnoreCase) == 0) { var res = new TemplateMatchResult { IsPartialMatch = true }; if (strToSearch.StartsWith(search, StringComparison.OrdinalIgnoreCase)) { res.StartsWith = true; } return(res); } return(new TemplateMatchResult()); }
internal TemplateMatchResult Combine(IEnumerable <TemplateMatchResult> matches) { if (matches == null || matches.Count() <= 0) { throw new ArgumentNullException("matches"); } var result = new TemplateMatchResult(); foreach (var m in matches) { result = Combine(result, m); } return(result); }
internal TemplateMatchResult IsStringMatch(string search, IEnumerable <string> strToSearch) { if (string.IsNullOrWhiteSpace(search) || strToSearch == null || strToSearch.Count() <= 0) { return(new TemplateMatchResult()); } var result = new TemplateMatchResult(); List <TemplateMatchResult> matches = new List <TemplateMatchResult>(); foreach (var str in strToSearch) { result = Combine(result, IsStringMatch(search, str)); } return(result); }
internal TemplateMatchResult Combine(TemplateMatchResult match1, TemplateMatchResult match2) { if (match1 == null) { throw new ArgumentNullException("match1"); } if (match2 == null) { throw new ArgumentNullException("match2"); } return(new TemplateMatchResult { IsExactMatch = (match1.IsExactMatch || match2.IsExactMatch), IsPartialMatch = (match1.IsPartialMatch || match2.IsPartialMatch), StartsWith = (match1.StartsWith || match2.StartsWith) }); }