コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }