internal override void Update(SettingItem other) { var owners = other as OwnersItem; if (!owners.Content.Any()) { throw new InvalidOperationException(Resources.OwnersItemMustHaveAtLeastOneOwner); } base.Update(other); if (!Equals(owners)) { XElementUtility.RemoveIndented(_content.Node); Content = owners.Content; _content = new SettingText(string.Join(OwnersListSeparator.ToString(), Content)); if (Origin != null) { _content.SetOrigin(Origin); if (Node != null) { _content.SetNode(_content.AsXNode()); (Node as XElement).Add(_content.Node); Origin.IsDirty = true; } } } }
public OwnersItem(string owners) : base() { if (string.IsNullOrEmpty(owners)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(owners)); } _content = new SettingText(owners); Content = owners.Split(OwnersListSeparator).Select(o => o.Trim()).ToList(); }
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(); }