예제 #1
0
        public static IpAddressLocation GetIpAddressLocation(IPAddress ipAddress)
        {
            var ipAddressIntegerRepresentation = ipAddress.ToInteger();

            InitCache();

            var correspondingRange = Cache.FirstOrDefault(r => r.StartIP <= ipAddressIntegerRepresentation
                                                               && r.EndIP >= ipAddressIntegerRepresentation);
            return correspondingRange != null ?
                new IpAddressLocation(correspondingRange.ISO_Code_2)
                : new IpAddressLocation();
        }