示例#1
0
        internal Uri CreateUri(string scheme, Uri relativeUri)
        {
            Uri baseUri = base_addresses.Contains(scheme) ? base_addresses [scheme] : null;

            if (relativeUri == null)
            {
                return(baseUri);
            }
            if (relativeUri.IsAbsoluteUri)
            {
                return(relativeUri);
            }
            if (baseUri == null)
            {
                return(null);
            }
            var s = relativeUri.ToString();

            if (s.Length == 0)
            {
                return(baseUri);
            }
            var l = baseUri.LocalPath;
            var r = relativeUri.ToString();

            if (l.Length > 0 && l [l.Length - 1] != '/' && r [0] != '/')
            {
                return(new Uri(String.Concat(baseUri.ToString(), "/", r)));
            }
            else
            {
                return(new Uri(String.Concat(baseUri.ToString(), r)));
            }
        }
示例#2
0
        internal static Uri GetVia(string scheme, Uri address, UriSchemeKeyedCollection baseAddresses)
        {
            Uri uri = address;

            if (uri.IsAbsoluteUri)
            {
                return(uri);
            }
            if (!baseAddresses.Contains(scheme))
            {
                return(null);
            }
            return(GetUri(baseAddresses[scheme], address));
        }