src/packages/EmbedIO/Utilities/IPParser.cs
/// <summary>
/// Determines whether the IP-range string is in simple IP range notation.
/// </summary>
/// <param name="range">The IP-range string.</param>
/// <returns>
///   <c>true</c> if the IP-range string is in simple IP range notation; otherwise, <c>false</c>.
/// </returns>
Determines whether the IP-range string is in simple IP range notation.
Determines whether the IP - range string is in simple IP range notation .
public static bool IsSimpleIPRange(string range)
        {
            if (string.IsNullOrWhiteSpace(range))
                return false;
            var parts = range.Split('.');
            if (parts.Length != 4)
                return false;
            foreach (var part in parts)
            {
                var rangeParts = part.Split('-');
                if (rangeParts.Length < 1 || rangeParts.Length > 2)
                    return false;
                if (!byte.TryParse(rangeParts[0], out _) ||
                    (rangeParts.Length > 1 && !byte.TryParse(rangeParts[1], out _)))
                    return false;
            }
            return true;
        }
public static bool IsSimpleIPRange ( string range ) { if ( string . IsNullOrWhiteSpace ( range ) ) return false ; var parts = range . Split ( ' ' ) ; if ( parts . Length != 4 ) return false ; foreach ( var part in parts ) { var rangeParts = part . Split ( ' ' ) ; if ( rangeParts . Length < 1 || rangeParts . Length > 2 ) return false ; if ( ! byte . TryParse ( rangeParts [ 0 ] , out _ ) || ( rangeParts . Length > 1 && ! byte . TryParse ( rangeParts [ 1 ] , out _ ) ) ) return false ; } return true ; }
Determines whether the IP-range string is in simple IP range notation.
Determines whether the IP - range string is in simple IP range notation .
None
range
string
The IP-range string.
The IP - range string .