Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 FolderResource(LinkPath path)
 {
     Path = path;
 }
Exemplo n.º 7
0
 public static bool TryFrom(string path, string query, out HttpResource resource) =>
 TryFrom(LinkPath.From(path, _pathSeparators), query, out resource);
Exemplo n.º 8
0
        public static bool TryFrom(LinkPath path, string query, out HttpResource resource)
        {
            resource = HttpQuery.TryFrom(query, out var parsedQuery) ? new HttpResource(path, parsedQuery) : null;

            return(resource != null);
        }
Exemplo n.º 9
0
 HttpResource(LinkPath path, HttpQuery query)
 {
     Path  = path;
     Query = query;
 }
Exemplo n.º 10
0
 public static HttpResource From(LinkPath path) =>
 From(path, HttpQuery.Empty);
Exemplo n.º 11
0
 public new static FolderResource From(string value, bool strict = true)
 {
     return(new FolderResource(LinkPath.From(value, _separators)));
 }
Exemplo n.º 12
0
 public static HttpResource From(LinkPath path, string query) =>
 new HttpResource(path, HttpQuery.From(query));
Exemplo n.º 13
0
 public static HttpResource From(LinkPath path, HttpQuery query) =>
 new HttpResource(path, query);
Exemplo n.º 14
0
        //
        // Factory
        //

        public static FolderResource From(LinkPath path) =>
        new FolderResource(path);
Exemplo n.º 15
0
 public static HttpResource From(string path, HttpQuery query) =>
 new HttpResource(LinkPath.From(path, _pathSeparators), query);
Exemplo n.º 16
0
 public new static FolderResource From(string value) =>
 new FolderResource(LinkPath.From(value, _separators));
Exemplo n.º 17
0
        //
        // Factory
        //

        public static FolderResource From(LinkPath path)
        {
            return(new FolderResource(path));
        }