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); }
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))); }
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))); }