/// <summary> /// Default constructor. /// </summary> /// <param name="pattern"></param> public AddressCondition(string pattern) { if (pattern == null) { throw new ArgumentNullException("pattern"); } _range = IPRange.Parse(pattern); }
/// <summary> /// Constructor. /// </summary> /// <param name="minimumAddress">Lowest IP address.</param> /// <param name="maximumAddress">Highest IP address.</param> public IPRange(IPAddress minimumAddress, IPAddress maximumAddress) { if (IPRange.Compare(minimumAddress, maximumAddress) == -1) { _minimumAddress = minimumAddress; _maximumAddress = maximumAddress; } else { _minimumAddress = maximumAddress; _maximumAddress = minimumAddress; } }
/// <summary> /// Deteremines if the given IP address is in the range. /// </summary> /// <param name="address">The IP address.</param> /// <returns>True if the address is in the range.</returns> public bool InRange(IPAddress address) { return(Compare(MinimumAddress, address) <= 0 && IPRange.Compare(address, MaximumAddress) <= 0); }