public void AddLevel2(string[] match, string[] actual)
        {
            var matched = Level2Matches(actual[0], match[1]).FirstOrDefault();

            if (matched != null)
            {
                level2Matches.Remove(matched);
            }
            Level2Match level2Match = new Level2Match();

            level2Match.Level1    = actual[0];
            level2Match.Level2    = actual[1];
            level2Match.AltLevel2 = match[1];
            level2Matches.Add(level2Match);
        }
Esempio n. 2
0
        private Level2Match SavedLevel2Match(CodedLocation location)
        {
            IEnumerable <Level2Match> matches =
                matchProvider.GetMatches(location.Name2, location.GeoCode1.Name).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}] [{2}",
                    count,
                    location.GeoCode1.Name,
                    location.Name2);
                throw new InvalidOperationException(msg);
            }
            Level2Match match = matches.FirstOrDefault();

            return(match);
        }
Esempio n. 3
0
        public MatchResult GetSavedMatchLevel2(string level2, string level1)
        {
            IEnumerable <Level2Match> matches =
                matchProvider.GetMatches(level2, 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}] [{2}",
                    count,
                    level1,
                    level2);
                throw new InvalidOperationException(msg);
            }
            Level2Match match = matches.FirstOrDefault();

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