Exemplo n.º 1
0
        protected void SetUri(Uri baseAddress, string relativeAddress)
        {
            Uri fullUri = baseAddress;

            // Ensure that baseAddress Path does end with a slash if we have a relative address
            if (relativeAddress != string.Empty)
            {
                if (!baseAddress.AbsolutePath.EndsWith("/", StringComparison.Ordinal))
                {
                    UriBuilder uriBuilder = new UriBuilder(baseAddress);
                    TcpChannelListener.FixIpv6Hostname(uriBuilder, baseAddress);
                    uriBuilder.Path = uriBuilder.Path + "/";
                    baseAddress     = uriBuilder.Uri;
                }

                fullUri = new Uri(baseAddress, relativeAddress);

                // now see if we need to update our base address (for cases like relative path = "/foo")
                if (!baseAddress.IsBaseOf(fullUri))
                {
                    baseAddress = fullUri;
                }
            }

            this.baseUri = baseAddress;
            ValidateUri(fullUri);
            this.uri = fullUri;
        }
        static Uri BuildUri(string host, int port, Guid guid)
        {
            UriBuilder uriBuilder = new UriBuilder();

            uriBuilder.Host = host;
            if (port > 0)
            {
                uriBuilder.Port = port;
            }
            uriBuilder.Path   = PeerStrings.KnownServiceUriPrefix + '/' + guid;
            uriBuilder.Scheme = Uri.UriSchemeNetTcp;
            TcpChannelListener.FixIpv6Hostname(uriBuilder, uriBuilder.Uri);
            return(uriBuilder.Uri);
        }
        private static Uri BuildUri(string host, int port, Guid guid)
        {
            UriBuilder uriBuilder = new UriBuilder {
                Host = host
            };

            if (port > 0)
            {
                uriBuilder.Port = port;
            }
            uriBuilder.Path   = "PeerChannelEndpoints" + '/' + guid;
            uriBuilder.Scheme = Uri.UriSchemeNetTcp;
            TcpChannelListener.FixIpv6Hostname(uriBuilder, uriBuilder.Uri);
            return(uriBuilder.Uri);
        }
        public static Uri GetListenUri(Uri baseAddress, string relativeAddress)
        {
            Uri uri = baseAddress;

            if (string.IsNullOrEmpty(relativeAddress))
            {
                return(uri);
            }
            if (!baseAddress.AbsolutePath.EndsWith("/", StringComparison.Ordinal))
            {
                UriBuilder uriBuilder = new UriBuilder(baseAddress);
                TcpChannelListener.FixIpv6Hostname(uriBuilder, baseAddress);
                uriBuilder.Path = uriBuilder.Path + "/";
                baseAddress     = uriBuilder.Uri;
            }
            return(new Uri(baseAddress, relativeAddress));
        }
        public static Uri GetListenUri(Uri baseAddress, string relativeAddress)
        {
            Uri fullUri = baseAddress;

            // Ensure that baseAddress Path does end with a slash if we have a relative address
            if (!String.IsNullOrEmpty(relativeAddress))
            {
                if (!baseAddress.AbsolutePath.EndsWith("/", StringComparison.Ordinal))
                {
                    UriBuilder uriBuilder = new UriBuilder(baseAddress);
                    TcpChannelListener.FixIpv6Hostname(uriBuilder, baseAddress);
                    uriBuilder.Path = uriBuilder.Path + "/";
                    baseAddress     = uriBuilder.Uri;
                }

                fullUri = new Uri(baseAddress, relativeAddress);
            }

            return(fullUri);
        }
Exemplo n.º 6
0
 protected void SetUri(System.Uri baseAddress, string relativeAddress)
 {
     System.Uri uri = baseAddress;
     if (relativeAddress != string.Empty)
     {
         if (!baseAddress.AbsolutePath.EndsWith("/", StringComparison.Ordinal))
         {
             UriBuilder uriBuilder = new UriBuilder(baseAddress);
             TcpChannelListener.FixIpv6Hostname(uriBuilder, baseAddress);
             uriBuilder.Path = uriBuilder.Path + "/";
             baseAddress     = uriBuilder.Uri;
         }
         uri = new System.Uri(baseAddress, relativeAddress);
         if (!baseAddress.IsBaseOf(uri))
         {
             baseAddress = uri;
         }
     }
     this.baseUri = baseAddress;
     this.ValidateUri(uri);
     this.uri = uri;
 }
Exemplo n.º 7
0
        private static System.Uri AddSegment(System.Uri baseUri, System.Uri fullUri)
        {
            System.Uri uri = null;
            if (baseUri.AbsolutePath.Length >= fullUri.AbsolutePath.Length)
            {
                return(uri);
            }
            UriBuilder uriBuilder = new UriBuilder(baseUri);

            TcpChannelListener.FixIpv6Hostname(uriBuilder, baseUri);
            if (!uriBuilder.Path.EndsWith("/", StringComparison.Ordinal))
            {
                uriBuilder.Path = uriBuilder.Path + "/";
                baseUri         = uriBuilder.Uri;
            }
            string originalString = baseUri.MakeRelativeUri(fullUri).OriginalString;
            int    index          = originalString.IndexOf('/');
            string str2           = (index == -1) ? originalString : originalString.Substring(0, index);

            uriBuilder.Path = uriBuilder.Path + str2;
            return(uriBuilder.Uri);
        }
Exemplo n.º 8
0
        static Uri AddSegment(Uri baseUri, Uri fullUri)
        {
            Uri result = null;

            if (baseUri.AbsolutePath.Length < fullUri.AbsolutePath.Length)
            {
                UriBuilder builder = new UriBuilder(baseUri);
                TcpChannelListener.FixIpv6Hostname(builder, baseUri);
                if (!builder.Path.EndsWith("/", StringComparison.Ordinal))
                {
                    builder.Path = builder.Path + "/";
                    baseUri      = builder.Uri;
                }
                Uri    relativeUri  = baseUri.MakeRelativeUri(fullUri);
                string relativePath = relativeUri.OriginalString;
                int    slashIndex   = relativePath.IndexOf('/');
                string segment      = (slashIndex == -1) ? relativePath : relativePath.Substring(0, slashIndex);
                builder.Path = builder.Path + segment;
                result       = builder.Uri;
            }
            return(result);
        }