public static bool TryFrom(string value, out HttpLink link) { link = null; var schemeParts = value.Split(new[] { Uri.SchemeDelimiter }, StringSplitOptions.None); if (schemeParts.Length == 2) { var pathSeparatorIndex = schemeParts[1].IndexOf('/'); if (pathSeparatorIndex == -1 || pathSeparatorIndex == schemeParts[1].Length - 1) { if (HttpHost.TryFrom(value, out var parsedHost)) { link = new HttpLink(parsedHost, HttpResource.Root); } } else { var hostText = schemeParts[0] + Uri.SchemeDelimiter + schemeParts[1].Substring(0, pathSeparatorIndex); var resourceText = schemeParts[1].Substring(pathSeparatorIndex + 1); if (HttpHost.TryFrom(hostText, out var parsedHost)) { if (HttpResource.TryFrom(resourceText, out var parsedResource)) { link = new HttpLink(parsedHost, parsedResource); } } } } return(link != null); }
public static bool TryFrom(string host, string resource, out HttpLink link) { link = null; if (HttpHost.TryFrom(host, out var parsedHost)) { if (HttpResource.TryFrom(resource, out var parsedResource)) { link = new HttpLink(parsedHost, parsedResource); } } return(link != null); }
public static bool TryFrom(string host, HttpResource resource, out HttpLink link) { link = HttpHost.TryFrom(host, out var parsedHost) ? new HttpLink(parsedHost, resource) : null; return(link != null); }