internal static EndPoint TryParseEndPoint(string endpoint) { if (string.IsNullOrWhiteSpace(endpoint)) { return(null); } string host; int port; int i = endpoint.IndexOf(':'); if (i < 0) { host = endpoint; port = 0; } else { host = endpoint.Substring(0, i); var portAsString = endpoint.Substring(i + 1); if (string.IsNullOrEmpty(portAsString)) { return(null); } if (!Format.TryParseInt32(portAsString, out port)) { return(null); } } if (string.IsNullOrWhiteSpace(host)) { return(null); } return(Format.ParseEndPoint(host, port)); }
/// <summary> /// Adds a new endpoint to the list /// </summary> public void Add(string host, int port) { Add(Format.ParseEndPoint(host, port)); }