コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public new static FolderResource From(string value) =>
 new FolderResource(LinkPath.From(value, _separators));
コード例 #7
0
 public static bool TryFrom(string path, string query, out HttpResource resource) =>
 TryFrom(LinkPath.From(path, _pathSeparators), query, out resource);
コード例 #8
0
 public static HttpResource From(string path, HttpQuery query) =>
 new HttpResource(LinkPath.From(path, _pathSeparators), query);
コード例 #9
0
ファイル: FolderResource.cs プロジェクト: snickroger/Totem
 public new static FolderResource From(string value, bool strict = true)
 {
     return(new FolderResource(LinkPath.From(value, _separators)));
 }