public NetworkAddressLocator_IP2LocationCsv(string filePath) { var fileLines = File.ReadAllLines(filePath); var trailingEof = string.IsNullOrWhiteSpace(fileLines[fileLines.Length - 1]); m_records = new RecordIP4[fileLines.Length - (trailingEof ? 1 : 0)]; for (var i = 0; i < m_records.Length; i++) { var fields = CsvReader.ParseLine(fileLines[i]); var ipFirst = uint.Parse(fields[0]); var ipLast = uint.Parse(fields[1]); var countryCode = string.Intern(fields[2]); var country = string.Intern(fields[3]); var region = string.Intern(fields[4]); var city = string.Intern(fields[5]); var lat = float.Parse(fields[6]); var lon = float.Parse(fields[7]); m_records[i] = new RecordIP4(ipFirst, ipLast, new Location(countryCode, country, region, city, new Coordinates(lat, lon))); } GC.Collect(); }
public static uint GetKey(RecordIP4 record) { return(record.IP4First); }