Esempio n. 1
0
        protected override string OnAddingTag(string tagText)
        {
            var exactMatch = AutoCompletionSuggestions.FirstOrDefault(suggestion => suggestion.Text == tagText);

            if (exactMatch == null)
            {
                var alternativeMatch = AutoCompletionSuggestions
                                       .FirstOrDefault(suggestion => suggestion.Text.StartsWith(tagText))?.Text;

                tagText = alternativeMatch ?? tagText;
            }

            return(tagText);
        }
Esempio n. 2
0
        private void UpdateAutoCompleteSuggestions(string searchTerm)
        {
            using (AutoCompletionSuggestions.EnterMassUpdate())
            {
                AutoCompletionSuggestions.Clear();
                searchTerm = searchTerm?.Trim();
                if (string.IsNullOrEmpty(searchTerm))
                {
                    return;
                }

                var newSuggestions = _tagIndex
                                     .GetRecommendations(Tags.Select(t => t.Text), searchTerm)
                                     .Select(result => new SuggestionModel(result.SearchTag, SuggestionChosen))
                                     .Take(10);

                AutoCompletionSuggestions.AddRange(newSuggestions);
            }
        }