/// <summary>
        ///     Determines whether a string is a valid special service address.
        /// </summary>
        /// <returns>
        ///     <see langword="true" /> if <paramref name="str" /> is a valid special service address; otherwise,
        ///     <see langword="false" />.
        /// </returns>
        /// <param name="str">The string to validate.</param>
        /// <param name="specialAddress">The <see cref="SpecialAddress" /> version of the string.</param>
        public static bool TryParse(string str, out SpecialAddress specialAddress)
        {
            if (DNSService.TryParse(str, out var dns))
            {
                specialAddress = dns;

                return(true);
            }

            if (DHCPService.TryParse(str, out var dhcp))
            {
                specialAddress = dhcp;

                return(true);
            }

            if (WINSService.TryParse(str, out var wins))
            {
                specialAddress = wins;

                return(true);
            }

            if (LocalSubnet.TryParse(str, out var localSubnet))
            {
                specialAddress = localSubnet;

                return(true);
            }

            if (DefaultGateway.TryParse(str, out var defaultGateway))
            {
                specialAddress = defaultGateway;

                return(true);
            }

            specialAddress = null;

            return(false);
        }
Exemple #2
0
 /// <summary>
 ///     Determines whether a string is a valid default gateway address
 /// </summary>
 /// <returns>
 ///     <see langword="true" /> if <paramref name="str" /> is a valid default gateway address; otherwise,
 ///     <see langword="false" />.
 /// </returns>
 /// <param name="str">The string to validate.</param>
 /// <param name="address">The <see cref="DefaultGateway" /> instance that represents the passed string.</param>
 public static bool TryParse(string str, out DefaultGateway address)
 {
     return(TryParse <DefaultGateway>(str, out address));
 }