示例#1
0
 MySqlCommand GetFindByIPCommand([NotNull] IPAddress address, int limit)
 {
     if (address == null)
     {
         throw new ArgumentNullException("address");
     }
     findByIPCommand.Parameters[0].Value = address.AsInt();
     findByIPCommand.Parameters[1].Value = limit;
     return(findByIPCommand);
 }
示例#2
0
        public static IPAddress RangeMax([NotNull] this IPAddress thisAddr, byte range)
        {
            if (thisAddr == null)
            {
                throw new ArgumentNullException("thisAddr");
            }
            if (range > 32)
            {
                throw new ArgumentOutOfRangeException("range");
            }
            int thisAsInt = thisAddr.AsInt();
            int mask      = (int)~NetMask(range);

            return(new IPAddress((uint)IPAddress.HostToNetworkOrder(thisAsInt | mask)));
        }
示例#3
0
        public static IPAddress RangeMin(this IPAddress thisAddr, byte range)
        {
            if (thisAddr == null)
            {
                throw new ArgumentNullException(nameof(thisAddr));
            }
            if (range > 32)
            {
                throw new ArgumentOutOfRangeException(nameof(range));
            }
            int thisAsInt = thisAddr.AsInt();
            int mask      = (int)NetMask(range);

            return(new IPAddress(IPAddress.HostToNetworkOrder(thisAsInt & mask)));
        }