Esempio n. 1
0
        public new static HttpLink From(string value, bool strict = true)
        {
            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)
                {
                    var host = HttpHost.From(value, strict: false);

                    if (host != null)
                    {
                        return(new HttpLink(host, HttpResource.Root));
                    }
                }
                else
                {
                    var hostText     = schemeParts[0] + Uri.SchemeDelimiter + schemeParts[1].Substring(0, pathSeparatorIndex);
                    var resourceText = schemeParts[1].Substring(pathSeparatorIndex + 1);

                    var host = HttpHost.From(hostText, strict: false);

                    if (host != null)
                    {
                        var resource = HttpResource.From(resourceText, strict: false);

                        if (resource != null)
                        {
                            return(new HttpLink(host, resource));
                        }
                    }
                }
            }

            ExpectNot(strict, "Failed to parse HTTP link: " + value);

            return(null);
        }
Esempio n. 2
0
        public static HttpLink From(string host, HttpResource resource, bool strict = true)
        {
            var parsedHost = HttpHost.From(host, strict);

            return(parsedHost == null ? null : new HttpLink(parsedHost, resource));
        }
Esempio n. 3
0
        public static HttpLink From(HttpHost host, string resource, bool strict = true)
        {
            var parsedResource = HttpResource.From(resource, strict);

            return(parsedResource == null ? null : new HttpLink(host, parsedResource));
        }
Esempio n. 4
0
        //
        // Factory
        //

        public static HttpLink From(HttpHost host, HttpResource resource)
        {
            return(new HttpLink(host, resource));
        }
Esempio n. 5
0
 public HttpLink Then(HttpResource resource)
 {
     return(new HttpLink(Host, Resource.Then(resource)));
 }
Esempio n. 6
0
 private HttpLink(HttpHost host, HttpResource resource)
 {
     Host     = host;
     Resource = resource;
 }