Advertisement
tolikpunkoff

SHARE TWEET GetCountryMem SxGeoSharp function

Sep 30th, 2018
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. //Поиск информации о стране по ID в памяти
  2.         private Dictionary<string, object> GetCountryMem(byte CountryID)
  3.         {
  4.             uint Readed = 0;            
  5.             uint NextRead = Header.CountrySize;
  6.             SxGeoUnpack Unpacker = new SxGeoUnpack(Header.pack_country, Header.DBEncoding);
  7.  
  8.             while (Readed < Header.CountrySize - 1)
  9.             {
  10.                 //читаем запись
  11.                 byte[] buf = bSubstr(cities_db, Readed, NextRead);
  12.  
  13.                 //распаковываем запись
  14.                 int RealLength = 0;
  15.                 Dictionary<string, object> Record = Unpacker.Unpack(buf,
  16.                     out RealLength);
  17.  
  18.                 //проверяем, не нашли ли запись
  19.                 if ((byte)Record["id"] == CountryID)
  20.                 {
  21.                     return Record;
  22.                 }
  23.                
  24.                 //Сохраняем количество фактических байт записи
  25.                 Readed += (uint)RealLength;                
  26.             }
  27.  
  28.             return null;
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement