public bool DeepEquals(SettingSection other) { if (!Equals(other)) { return(false); } return(string.Equals(ElementName, other.ElementName, StringComparison.Ordinal) && Items.SequenceEqual(other.Items)); }
public IReadOnlyList <PackageNamespacesSourceItem> GetPackageSourceNamespaces() { SettingSection packageNamespacesSection = _settings.GetSection(ConfigurationConstants.PackageNamespaces); if (packageNamespacesSection == null) { return(Enumerable.Empty <PackageNamespacesSourceItem>().ToList()); } return(packageNamespacesSection.Items.OfType <PackageNamespacesSourceItem>().ToList()); }
public bool Equals(SettingSection other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(ElementName, other.ElementName, StringComparison.Ordinal)); }
internal VirtualSettingSection Merge(SettingSection other) { if (!Equals(other)) { throw new ArgumentException(Resources.Error_MergeTwoDifferentSections); } foreach (var item in other.Items.Where(item => item != null)) { if (item is ClearItem) { if (CanBeCleared) { Children.Clear(); } Children.Add(item); continue; } if (TryGetChild(item, out var currentItem)) { if (item is UnknownItem unknown) { unknown.Merge(currentItem as UnknownItem); } item.MergedWith = currentItem; Children.Remove(currentItem); Children.Add(item); } else { Children.Add(item); } } return(this); }
internal VirtualSettingSection Merge(SettingSection other) { if (!Equals(other)) { throw new ArgumentException(Resources.Error_MergeTwoDifferentSections); } foreach (var item in other.Items.Where(item => item != null)) { if (item is ClearItem) { if (CanBeCleared) { ChildrenSet.Clear(); } ChildrenSet.Add(item, item); continue; } if (ChildrenSet.ContainsKey(item)) { if (item is UnknownItem unknown) { unknown.Merge(ChildrenSet[item] as UnknownItem); } item.MergedWith = ChildrenSet[item]; ChildrenSet[item] = item; } else { ChildrenSet.Add(item, item); } } return(this); }
public IReadOnlyList <ClientCertItem> GetClientCertificates() { SettingSection clientCertificatesSection = _settings.GetSection(ConfigurationConstants.ClientCertificates); if (clientCertificatesSection == null) { return(Enumerable.Empty <ClientCertItem>().ToList()); } var result = clientCertificatesSection.Items.OfType <ClientCertItem>().ToList(); //Distinct by PackageSource var groupedByPackageSourceItems = result.ToLookup(i => i.PackageSource, i => i, StringComparer.OrdinalIgnoreCase); var groupsWithSamePackageSource = groupedByPackageSourceItems.Where(g => g.Count() > 1).ToList(); if (groupsWithSamePackageSource.Any()) { var message = string.Format(Resources.ClientCertificateDuplicateConfiguration, string.Join(", ", $"'{groupsWithSamePackageSource.Select(g => g.Key)}'")); throw new NuGetConfigurationException(message); } return(result); }
/// <remarks> /// This method gives you a reference to the actual abstraction instead of a clone of it. /// It should be used only when intended. For most purposes you should be able to use /// GetSection(...) instead. /// </remarks> internal bool TryGetSection(string sectionName, out SettingSection section) { return(_rootElement.Sections.TryGetValue(sectionName, out section)); }
internal VirtualSettingSection(SettingSection section) : this(section.ElementName, section.Attributes, section.Items) { }