public static FolderLink FromLocal(string value, bool strict = true) { var parsedFolder = FolderResource.From(value, strict); if (parsedFolder != null && parsedFolder.Path.Segments.Count > 0) { var path = parsedFolder.Path.Segments.Count == 1 ? LinkPath.Root : LinkPath.From(parsedFolder.Path.Segments.Skip(1)); return(new FolderLink(parsedFolder.Path.Segments[0], FolderResource.From(path))); } Expect(strict, "Cannot parse folder link: " + value); return(null); }
public static bool TryFromLocal(string value, out FolderLink link) { link = null; var path = FolderResource.From(value).Path; if (path.Segments.Any()) { var root = path.Segments[0]; var resource = path.Segments.Count == 1 ? LinkPath.Root : LinkPath.From(path.Segments.Skip(1)); link = new FolderLink(root, FolderResource.From(resource)); } return(link != null); }
public static bool TryFromUnc(string value, out FolderLink link) { link = null; if (!String.IsNullOrEmpty(value) && HasUncPrefix(value)) { var path = FolderResource.From(value.Substring(2)).Path; var root = $@"\\{path.Segments[0]}"; var resource = path.Segments.Count == 1 ? LinkPath.Root : LinkPath.From(path.Segments.Skip(1)); link = new FolderLink(root, FolderResource.From(resource), isUnc: true); } return(link != null); }
public static bool TryFrom(string value, out HttpResource resource) { var parts = value.Split(QuerySeparator); var path = LinkPath.From(parts[0], _pathSeparators); if (parts.Length == 1) { resource = new HttpResource(path, HttpQuery.Empty); } else if (HttpQuery.TryFrom(parts[1], out var parsedQuery)) { resource = new HttpResource(path, parsedQuery); } else { resource = null; } return(resource != null); }
public static FolderLink FromUnc(string value, bool strict = true) { if (!String.IsNullOrEmpty(value) && value.StartsWith(@"\\")) { var parsedFolder = FolderResource.From(value.Substring(2), strict); if (parsedFolder != null) { var root = @"\\" + parsedFolder.Path.Segments[0].ToString(); var path = parsedFolder.Path.Segments.Count == 1 ? LinkPath.Root : LinkPath.From(parsedFolder.Path.Segments.Skip(1)); return(new FolderLink(root, FolderResource.From(path), isUnc: true)); } } ExpectNot(strict, "Cannot parse UNC link: " + value); return(null); }
public new static FolderResource From(string value) => new FolderResource(LinkPath.From(value, _separators));
public static bool TryFrom(string path, string query, out HttpResource resource) => TryFrom(LinkPath.From(path, _pathSeparators), query, out resource);
public static HttpResource From(string path, HttpQuery query) => new HttpResource(LinkPath.From(path, _pathSeparators), query);
public new static FolderResource From(string value, bool strict = true) { return(new FolderResource(LinkPath.From(value, _separators))); }