public void Add(Uri uri, ICredentials credentials)
        {
            Uri rootUri = UriUtility.GetRootUri(uri);

            _credentialCache.TryAdd(uri, credentials);
            _credentialCache.AddOrUpdate(rootUri, credentials, (u, c) => credentials);
        }
        public ICredentials GetCredentials(Uri uri)
        {
            Uri rootUri = UriUtility.GetRootUri(uri);

            ICredentials credentials;

            if (_credentialCache.TryGetValue(uri, out credentials) ||
                _credentialCache.TryGetValue(rootUri, out credentials))
            {
                return(credentials);
            }

            return(null);
        }