public CitiesIndex(byte[] dataBase, uint index) { ItemIndex = index; var offset = new GeoBaseHeader(dataBase).OffsetCities; var startIndex = (int)(offset + (CITIES_ROW_SIZE)*index); if (dataBase.Length < startIndex + CITIES_ROW_SIZE) { throw new InvalidOperationException("Can't read Cities index Row. Not enough data in DataBase."); } LocationInfoIndex = BitConverter.ToUInt32(dataBase, startIndex); Location = LocationInfo.FromAbsolutePostition(dataBase, LocationInfoIndex); }
public IPRange(byte[] dataBase, int index) { var offset = new GeoBaseHeader(dataBase).OffsetRanges; var startIndex = (int)(offset + (RANGE_ROW_SIZE)*index); if (dataBase.Length < startIndex + RANGE_ROW_SIZE) { throw new InvalidOperationException("Can't read Ip Range Row. Not enough data in DataBase."); } IpFromStartIndex = startIndex; IpFrom = BitConverter.ToUInt32(dataBase, IpFromStartIndex); IpToStartIndex = startIndex + 4; IpTo = BitConverter.ToUInt32(dataBase, IpToStartIndex); var locationIndexStartIndex = IpToStartIndex + 4; LocationIndex = BitConverter.ToInt32(dataBase, locationIndexStartIndex); }