示例#1
0
文件: IPHost.cs 项目: ypid/jellyfin
        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}");
        }
示例#2
0
文件: IPHost.cs 项目: ypid/jellyfin
        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}");
        }