Example #1
0
        /// <summary>
        /// Checks whether the <see cref="IpRange"/> contains another specified <see cref="IpRange"/>.
        /// </summary>
        /// <param name="subRange">The IP range to be checked.</param>
        /// <returns>True if contains; otherwise false.</returns>
        public bool Contains(IpRange subRange)
        {
            if (subRange == null)
            {
                throw new ArgumentNullException(nameof(subRange));
            }

            if (subRange.Begin.AddressFamily != Begin.AddressFamily)
            {
                return(false);
            }

            return(subRange._low >= _low && subRange._high <= _high);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IpSet"/> class.
 /// </summary>
 /// <param name="range">The IP range.</param>
 public IpSet(IpRange range)
     : this(new[] { range })
 {
 }
        /// <summary>
        /// Checks whether the <see cref="IpRange"/> contains specified <see cref="IPAddress"/>.
        /// </summary>
        /// <param name="ipRange">The <see cref="IpRange"/> object.</param>
        /// <param name="ipAddress">The IP address to be checked.</param>
        /// <returns>True if contains; otherwise false.</returns>
        public static bool Contains(this IpRange ipRange, string ipAddress)
        {
            var address = IPAddress.Parse(ipAddress);

            return(ipRange.Contains(address));
        }