internal void Remove(SettingBase setting)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            if (Origin != null && Origin.IsMachineWide)
            {
                throw new InvalidOperationException(Resources.CannotUpdateMachineWide);
            }

            if (Origin != null && Origin.IsReadOnly)
            {
                throw new InvalidOperationException(Resources.CannotUpdateReadOnlyConfig);
            }

            if (_mutableChildren.TryGetValue(setting, out var currentSetting) && _mutableChildren.Remove(currentSetting))
            {
                currentSetting.RemoveFromSettings();

                if (Parent != null && IsEmpty())
                {
                    Parent.Remove(this);
                }
            }
        }
        internal bool Add(SettingBase setting)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            if (Origin != null && Origin.IsMachineWide)
            {
                throw new InvalidOperationException(Resources.CannotUpdateMachineWide);
            }

            if (Origin != null && Origin.IsReadOnly)
            {
                throw new InvalidOperationException(Resources.CannotUpdateReadOnlyConfig);
            }

            if (!_mutableChildren.ContainsKey(setting) && !setting.IsEmpty())
            {
                _mutableChildren.Add(setting, setting);

                if (Origin != null)
                {
                    setting.SetOrigin(Origin);

                    if (Node != null)
                    {
                        setting.SetNode(setting.AsXNode());

                        XElementUtility.AddIndented(Node as XElement, setting.Node);
                        Origin.IsDirty = true;
                    }
                }

                setting.Parent = this;

                return(true);
            }

            return(false);
        }
Beispiel #3
0
 public override bool Equals(SettingBase other) => Equals(other as ClearItem);
Beispiel #4
0
 public override bool Equals(SettingBase other) => Equals(other as NuGetConfiguration);
Beispiel #5
0
 public override bool Equals(SettingBase other) => Equals(other as SettingSection);
Beispiel #6
0
 public override bool DeepEquals(SettingBase other) => DeepEquals(other as UnknownItem);