コード例 #1
0
 public BestMatchSelector(string searchText)
 {
     this.searchText     = searchText ?? throw new ArgumentNullException(nameof(searchText));
     matchPriority       = MatchPriority.Nothing;
     bestCompletion      = null;
     acronymMatchIndexes = AcronymSearchHelpers.TryCreateMatchIndexes(searchText);
 }
コード例 #2
0
        public void Select(Completion completion)
        {
            var newMatchPriority = GetMatchPriority(completion);

            if (newMatchPriority < matchPriority)
            {
                bestCompletion = completion;
                matchPriority  = newMatchPriority;
            }
        }
コード例 #3
0
        public MatchPriority MatchOrder(DataRow trailRecord, DataTable targetTable)
        {
            MatchPriority highestMatch = MatchPriority.NONE;
            MatchPriority matchLevel   = highestMatch;

            foreach (DataRow targetRecord in targetTable.Rows)
            {
                string sourceValue = trailRecord["ORDERID"].ToString().Trim();
                string targetValue = targetRecord["ORDERID"].ToString().Trim();

                if (sourceValue.Equals(targetValue))
                {
                    matchLevel = MatchPriority.LEVEL3;
                }

                int matchCount = 0;
                foreach (string column in columnsToMatch)
                {
                    sourceValue = trailRecord[column].ToString().Trim();
                    targetValue = targetRecord[column].ToString().Trim();

                    if (sourceValue.Equals(targetValue))
                    {
                        matchCount++;
                    }
                }
                if (matchCount == columnsToMatch.Count)
                {
                    matchLevel = (matchLevel == MatchPriority.LEVEL3 ? MatchPriority.LEVEL5 : MatchPriority.LEVEL2);
                }
                else if (matchCount == 1)
                {
                    matchLevel = (matchLevel == MatchPriority.LEVEL3 ? MatchPriority.LEVEL4 : MatchPriority.LEVEL1);
                }
                else if (matchCount > 1)
                {
                    matchLevel = (matchLevel == MatchPriority.LEVEL3 ? MatchPriority.LEVEL4 : MatchPriority.LEVEL2);
                }

                if ((int)matchLevel > (int)highestMatch)
                {
                    highestMatch = matchLevel;
                }

                if (highestMatch == MatchPriority.LEVEL5)
                {
                    break;
                }
            }

            return(highestMatch);
        }
コード例 #4
0
		public BestMatchSelector(string searchText) {
			if (searchText == null)
				throw new ArgumentNullException(nameof(searchText));
			this.searchText = searchText;
			matchPriority = MatchPriority.Nothing;
			bestCompletion = null;
			acronymMatchIndexes = AcronymSearchHelpers.TryCreateMatchIndexes(searchText);
		}
コード例 #5
0
		public void Select(Completion completion) {
			var newMatchPriority = GetMatchPriority(completion);
			if (newMatchPriority < matchPriority) {
				bestCompletion = completion;
				matchPriority = newMatchPriority;
			}
		}