public static IPHost Parse(string host) { if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res)) { return(res); } throw new InvalidCastException("Host does not contain a valid value. {host}"); }
public static IPHost Parse(string host, AddressFamily family) { if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res)) { if (family == AddressFamily.InterNetwork) { res.Remove(AddressFamily.InterNetworkV6); } else { res.Remove(AddressFamily.InterNetwork); } return(res); } throw new InvalidCastException("Host does not contain a valid value. {host}"); }