internal PackageSourceMappingSourceItem(XElement element, SettingsFile origin) : base(element, origin) { _parsedDescendants = element.Nodes().Where(n => n is XElement || n is XText text && !string.IsNullOrWhiteSpace(text.Value)) .Select(e => SettingFactory.Parse(e, origin)); var parsedPackagePatternItems = _parsedDescendants.OfType <PackagePatternItem>().ToList(); if (parsedPackagePatternItems.Count == 0) { throw new NuGetConfigurationException(string.Format(CultureInfo.CurrentCulture, Resources.Error_ItemNeedsAtLeastOnePackagePatternWithPath, Key, origin.ConfigFilePath)); } Patterns = parsedPackagePatternItems; }
internal UnknownItem(XElement element, SettingsFile origin) : base(element, origin) { ElementName = element.Name.LocalName; _mutableChildren = new Dictionary <SettingBase, SettingBase>(); var descendants = element.Nodes().Where(n => n is XText text && !string.IsNullOrWhiteSpace(text.Value) || n is XElement) .Select(d => SettingFactory.Parse(d, origin)).Distinct(); foreach (var descendant in descendants) { descendant.Parent = this; _mutableChildren.Add(descendant, descendant); } }
internal TrustedSignerItem(XElement element, SettingsFile origin) : base(element, origin) { _parsedDescendants = element.Nodes().Where(n => n is XElement || n is XText text && !string.IsNullOrWhiteSpace(text.Value)) .Select(e => SettingFactory.Parse(e, origin)); var parsedCertificates = _parsedDescendants.OfType <CertificateItem>().ToList(); if (parsedCertificates.Count() < 1) { throw new NuGetConfigurationException( string.Format(CultureInfo.CurrentCulture, Resources.UserSettings_UnableToParseConfigFile, Resources.TrustedSignerMustHaveCertificates, origin.ConfigFilePath)); } Certificates = parsedCertificates; }
internal OwnersItem(XElement element, SettingsFile origin) : base(element, origin) { var descendants = element.Nodes().Where(n => n is XText text && !string.IsNullOrWhiteSpace(text.Value) || n is XElement) .Select(d => SettingFactory.Parse(d, origin)).Distinct(); if (descendants == null || descendants.Count() != 1 || descendants.FirstOrDefault(d => d is SettingText) == null) { throw new NuGetConfigurationException( string.Format(CultureInfo.CurrentCulture, Resources.UserSettings_UnableToParseConfigFile, Resources.OwnersMustOnlyHaveContent, origin.ConfigFilePath)); } _content = descendants.OfType <SettingText>().First(); Content = _content.Value.Split(OwnersListSeparator).Select(o => o.Trim()).ToList(); }