コード例 #1
0
        private AOTypeDictionary GetDictionaryFromSql()
        {
            var dictionary = new AOTypeDictionary();

            foreach (var type in DataContext.AddressObjectType)
            {
                if (!string.IsNullOrEmpty(type.SCNAME) && !bannedAbbriviatedNames.Contains(type.SCNAME))
                {
                    dictionary.Add(new AddressSplitterLib.AddressObjectType(type.SOCRNAME, type.SCNAME, type.LEVEL));
                }
                if (!string.IsNullOrEmpty(type.SOCRNAME) && !bannedAbbriviatedNames.Contains(type.SOCRNAME))
                {
                    dictionary.Add(new AddressSplitterLib.AddressObjectType(type.SOCRNAME, type.SOCRNAME, type.LEVEL));
                }
            }
            return(dictionary);
        }
コード例 #2
0
        public FiasParser(string connectionString)
        {
            DataContext = new FiasClassesDataContext(connectionString);
            DataContext.CommandTimeout = 0;
            if (!DataContext.DatabaseExists())
            {
                throw new BadLoginException("Не удалось подключиться к БД.");
            }

            bannedAbbriviatedNames = new List <string>();
            bannedAbbriviatedNames.Add("к.");
            bannedAbbriviatedNames.Add("вал");

            sb         = new StringBuilder();
            dictionary = GetDictionaryFromSql();

            dictionary.Add(new AddressSplitterLib.AddressObjectType("область", "область", 1, AddressSplitterLib.AddressObjectType.GenderNoun.Fiminine));
            dictionary.Add(new AddressSplitterLib.AddressObjectType("область", "обл", 1, AddressSplitterLib.AddressObjectType.GenderNoun.Fiminine));
            dictionary.Add(new AddressSplitterLib.AddressObjectType("проспект", "пр-т", 7));
            dictionary.Add(new AddressSplitterLib.AddressObjectType("проспект", "пр.", 7));
            dictionary.Add(new AddressSplitterLib.AddressObjectType("квартира", "к", 9));
            dictionary.Sort();
            parser = new AddressParser(dictionary);
        }