private bool TryGetCredentials(Uri uri, out NetworkCredential configurationCredentials)
        {
            var source = _packageSourceProvider.LoadPackageSources().FirstOrDefault(p =>
            {
                Uri sourceUri;
                return(!String.IsNullOrEmpty(p.UserName) &&
                       !String.IsNullOrEmpty(p.Password) &&
                       Uri.TryCreate(p.Source, UriKind.Absolute, out sourceUri) &&
                       UriUtility.UriStartsWith(sourceUri, uri));
            });

            if (source == null)
            {
                // The source is not in the config file
                configurationCredentials = null;
                return(false);
            }
            configurationCredentials = new NetworkCredential(source.UserName, source.Password);
            return(true);
        }
Exemplo n.º 2
0
        private bool TryGetCredentials(Uri uri, out NetworkCredential configurationCredentials)
        {
            PackageSource source = Enumerable.FirstOrDefault <PackageSource>(this._packageSourceProvider.LoadPackageSources(), delegate(PackageSource p) {
                Uri uri;
                return(!string.IsNullOrEmpty(p.UserName) && (!string.IsNullOrEmpty(p.Password) && (Uri.TryCreate(p.Source, UriKind.Absolute, out uri) && UriUtility.UriStartsWith(uri, uri))));
            });

            if (source == null)
            {
                configurationCredentials = null;
                return(false);
            }
            configurationCredentials = new NetworkCredential(source.UserName, source.Password);
            return(true);
        }