NuGet.CredentialProviderExtensions.AsCredentialCache C# (CSharp) Méthode

AsCredentialCache() static private méthode

static private AsCredentialCache ( this credentials, Uri uri ) : ICredentials
credentials this
uri System.Uri
Résultat ICredentials
        internal static ICredentials AsCredentialCache(this ICredentials credentials, Uri uri)
        {
            // No credentials then bail
            if (credentials == null)
            {
                return null;
            }

            // Do nothing with default credentials
            if (credentials == CredentialCache.DefaultCredentials ||
                credentials == CredentialCache.DefaultNetworkCredentials)
            {
                return credentials;
            }

            // If this isn't a NetworkCredential then leave it alone
            var networkCredentials = credentials as NetworkCredential;
            if (networkCredentials == null)
            {
                return credentials;
            }

            // Set this up for each authentication scheme we support
            // The reason we're using a credential cache is so that the HttpWebRequest will forward our
            // credentials if there happened to be any redirects in the chain of requests.
            var cache = new CredentialCache();
            foreach (var scheme in _authenticationSchemes)
            {
                cache.Add(uri, scheme, networkCredentials);
            }
            return cache;
        }
    }
CredentialProviderExtensions