Exemple #1
0
        private Level1Match SavedLevel1Match(CodedLocation location)
        {
            IEnumerable <Level1Match> matches =
                matchProvider.GetMatches(location.Name1).ToList();
            int count = matches.Count();

            if (count > 1)
            {
                // there must only be a max of one saved match for any given input.
                var msg = string.Format(
                    "[{0}] matched names found for the input [{1}]",
                    count,
                    location.Name1);
                throw new InvalidOperationException(msg);
            }
            Level1Match match = matches.FirstOrDefault();

            return(match);
        }
        public MatchResult GetSavedMatchLevel1(string level1)
        {
            IEnumerable <Level1Match> matches = matchProvider.GetMatches(level1).ToList();
            int count = matches.Count();

            if (count > 1)
            {
                // there must only be a max of one saved match for any given input.
                var msg = string.Format(
                    "[{0}] matched names found for the input [{1}]",
                    count,
                    level1);
                throw new InvalidOperationException(msg);
            }

            Level1Match match = matches.FirstOrDefault();

            return(match != null
                ? new MatchResult(match.Level1, DefaultProbability)
                : null);
        }