Пример #1
0
        private bool GetIsValidWholeWordMatch(GetMatchingLinesArgs args, string adjustedSearchLine, HighlightInfo match)
        {
            bool previousCharacterMatters = !LuceneHelper.IsValidTokenBreakCharactor(args.SearchString.FirstOrDefault());
            char previousCharacter        = adjustedSearchLine.ElementAtOrDefault(match.StartIndex - 1);

            bool nextCharacterMatters = !LuceneHelper.IsValidTokenBreakCharactor(args.SearchString.LastOrDefault());
            char nextCharacter        = adjustedSearchLine.ElementAtOrDefault(match.EndIndex);

            bool isValidWholeWordMatch = (!previousCharacterMatters || LuceneHelper.IsValidTokenBreakCharactor(previousCharacter)) &&
                                         (!nextCharacterMatters || LuceneHelper.IsValidTokenBreakCharactor(nextCharacter));

            return(isValidWholeWordMatch);
        }