Apache.NMS.Util.URISupport.ParseComposite C# (CSharp) Method

ParseComposite() public static method

public static ParseComposite ( Uri uri ) : CompositeData
uri System.Uri
return CompositeData
        public static CompositeData ParseComposite(Uri uri)
        {
            CompositeData rc = new CompositeData();
            rc.Scheme = uri.Scheme;

            // Start with original URI
            //String ssp = uri.Authority + uri.PathAndQuery;
            String ssp = uri.OriginalString;

            ssp = StripPrefix(ssp, rc.Scheme + ":");
            ssp = StripPrefix(ssp, "//");

            int lastPoundPos = ssp.LastIndexOf("#");
            int lastParendPos = ssp.LastIndexOf(")");

            // Only include a Fragment that's outside any Composte sections.
            if(lastPoundPos > lastParendPos)
            {
                rc.Fragment = ssp.Substring(lastPoundPos);
                ssp = ssp.Substring(0, lastPoundPos);
            }

            // Ensure any embedded URIs don't have malformed authority's by changing
            // them from '://(' which would cause the .NET Uri class to attempt to validate
            // the authority as a hostname with, ':(' which is valid.
            ssp = ssp.Replace("://(", ":(");

            // Handle the composite components
            ParseComposite(uri, rc, ssp);
            return rc;
        }

Same methods

URISupport::ParseComposite ( Uri uri, CompositeData rc, String ssp ) : void

Usage Example

        public IProvider CreateProvider(Uri remoteUri)
        {
            URISupport.CompositeData compositeData      = URISupport.ParseComposite(remoteUri);
            StringDictionary         filteredProperties = PropertyUtil.FilterProperties(compositeData.Parameters, FAILOVER_OPTION_PREFIX);
            FailoverProvider         failoverProvider   = new FailoverProvider(compositeData.Components);

            PropertyUtil.SetProperties(failoverProvider, filteredProperties);
            return(failoverProvider);
        }