private static IEnumerable FindClosestAndNextClosestAndPrefixedPairStringLexEntryForms( string text, IEnumerable items, IDisplayStringAdaptor adaptor) { return(ApproximateMatcher.FindClosestForms <object>(items, adaptor.GetDisplayLabel, text, ApproximateMatcherOptions. IncludePrefixedAndNextClosestForms)); }
private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text, IEnumerable items, IDisplayStringAdaptor adaptor) { return(ApproximateMatcher.FindClosestForms(items, text, ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms)); }
private static IEnumerable FilterList(string text, IEnumerable items, IDisplayStringAdaptor adaptor) { ICollection <object> newList = new Collection <object>(); foreach (object item in items) { string label = adaptor.GetDisplayLabel(item); if (label.ToLower().StartsWith(text.ToLower())) { newList.Add(item); break; } } return(newList); }
private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text, IEnumerable items, IDisplayStringAdaptor adaptor) { return ApproximateMatcher.FindClosestForms(items, text, ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms); }
private static IEnumerable FilterList(string text, IEnumerable items, IDisplayStringAdaptor adaptor) { ICollection<object> newList = new Collection<object>(); foreach (object item in items) { string label = adaptor.GetDisplayLabel(item); if (label.ToLower().StartsWith(text.ToLower())) { newList.Add(item); break; } } return newList; }
public OptionDisplayAdaptor(OptionsList allOptions, string preferredWritingSystemId) { _allOptions = allOptions; _preferredWritingSystemId = preferredWritingSystemId; _toolTipAdaptor = null; }
public IEnumerable GetItemsToOffer(string text, IEnumerable items, IDisplayStringAdaptor adaptor) { List <Option> show = new List <Option>(); #if !DEBUG try { #endif //enhance: make that text safe for regex. for now, we just swallow the exception string pattern = @"(^|[^\w])(" + text + @")[^\w]"; Regex MatchWholeWordNoCase = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); foreach (Option option in _allOptions.Options) { //todo: make this prefferd script(s) savvy if (option.Name.GetFirstAlternative().StartsWith(text, StringComparison. CurrentCultureIgnoreCase)) { show.Add(option); } } foreach (Option option in _allOptions.Options) { //todo: make this prefferd script(s) savvy if (option.Abbreviation.GetFirstAlternative().StartsWith(text, StringComparison.CurrentCultureIgnoreCase)) { if (!show.Contains(option)) { show.Add(option); } } } //this grabs up the DDP examples foreach (Option option in _allOptions.Options) { if (option.GetSearchKeys(_preferredWritingSystemId).Contains(text.ToLower())) { if (!show.Contains(option)) { show.Add(option); } } } // if(show.Count == 0) { foreach (Option option in _allOptions.Options) { //todo: make this prefferd script(s) savvy if (MatchWholeWordNoCase.IsMatch(option.Description.GetFirstAlternative())) { if (!show.Contains(option)) { show.Add(option); } } } } #if !DEBUG } catch (Exception /*e*/) { //not worth crashing over some regex problem } #endif return(show); }