public IEnumerable<PackageSource> LoadPackageSources()
{
IList<KeyValuePair<string, string>> settingsValue = _settingsManager.GetValues(PackageSourcesSectionName);
if (!settingsValue.IsEmpty())
{
// put disabled package source names into the hash set
IEnumerable<KeyValuePair<string, string>> disabledSourcesValues = _settingsManager.GetValues(DisabledPackageSourcesSectionName) ??
Enumerable.Empty<KeyValuePair<string, string>>();
var disabledSources = new HashSet<string>(disabledSourcesValues.Select(s => s.Key), StringComparer.CurrentCultureIgnoreCase);
var loadedPackageSources = settingsValue.
Select(p =>
{
string name = p.Key;
string src = p.Value;
NetworkCredential creds = ReadCredential(name);
// We always set the isOfficial bit to false here, as Core doesn't have the concept of an official package source.
return new PackageSource(src, name, isEnabled: !disabledSources.Contains(name), isOfficial: false)
{
UserName = creds != null ? creds.UserName : null,
Password = creds != null ? creds.Password : null
};
}).ToList();
if (_migratePackageSources != null)
{
MigrateSources(loadedPackageSources);
}
return loadedPackageSources;
}
return _defaultPackageSources;
}