Пример #1
0
        public virtual bool IsInRange(string ip)
        {
            try
            {
                if (IpFrom == IpTo)
                {
                    return(ip == IpFrom);
                }
                var ips = (from p in ip.Split('.') select Convert.ToInt32(p)).ToList();
                if (ips.Count() != 4)
                {
                    return(false);
                }

                var from = (from p in IpFrom.Split('.') select Convert.ToInt32(p)).ToList();
                var to   = (from p in IpTo.Split('.') select Convert.ToInt32(p)).ToList();

                for (var i = 0; i < 4; i++)
                {
                    if (ips[i] < from[i] || ips[i] > to[i])
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
        public override int GetHashCode()
        {
            var hashCode = -763417269;

            hashCode = hashCode * -1521134295 + IpFrom.GetHashCode();
            hashCode = hashCode * -1521134295 + IpTo.GetHashCode();
            hashCode = hashCode * -1521134295 + LocationIndex.GetHashCode();
            return(hashCode);
        }