/// <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);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Determines whether a string is a valid WINS service
 /// </summary>
 /// <returns>
 ///     <see langword="true" /> if <paramref name="str" /> is a valid WINS service; otherwise, <see langword="false" />.
 /// </returns>
 /// <param name="str">The string to validate.</param>
 /// <param name="service">The <see cref="WINSService" /> instance that represents the passed string.</param>
 public static bool TryParse(string str, out WINSService service)
 {
     return(TryParse <WINSService>(str, out service));
 }