internal static void ValidateChildForAssignment(SettingsNode child) { if (child.Parent != null) { throw new InvalidOperationException("Node already is a child of another node."); } }
/// <summary> /// Unsets the parent initiated with <see cref="AddSettingsChild"/>. /// This <see cref="SettingsNode"/> will no longer receive change notifications from the <paramref name="child"/>. /// </summary> /// <param name="child">The nested <see cref="SettingsNode"/>.</param> protected internal void RemoveSettingsChild(SettingsNode child) { if (this != child.Parent) { throw new InvalidOperationException("Trying to remove child node from parent that is not the actual parent of the child."); } child.Parent = null; }
/// <summary> /// Initializes a new instance of the <see cref="SettingsNodeCollection{T}"/> class. /// </summary> /// <param name="parent">The parent <see cref="SettingsNode"/>.</param> public SettingsNodeCollection(SettingsNode parent) { if (parent == null) { throw new ArgumentNullException(nameof(parent)); } this.Parent = parent; }
public void Dispose() { if (this.settingsNode == null) { throw new InvalidOperationException("Already disposed."); } var node = this.settingsNode; this.settingsNode = null; node.ExitEditScope(); }
/// <summary> /// Will recursively notify all <see cref="SettingsNode"/> for a settings change. /// </summary> /// <param name="args"><see cref="SettingsChangedEventArgs"/> that contain information about the change.</param> protected internal void NotifyChange(SettingsChangedEventArgs args) { if (args == null) { throw new ArgumentNullException("args"); } args.OriginalSource = this; SettingsNode target = this; while (target != null && !target.IsInEditScope) { target.RaiseSettingsChanged(args); target = target.Parent; } if (target != null) { target.AccumulateChanges(); } }
public EditScope(SettingsNode settingsNode) { this.settingsNode = settingsNode; this.settingsNode.EnterEditScope(); }
/// <summary> /// Set this <see cref="SettingsNode"/> as parent of the <paramref name="child"/> and becomes a target for the <paramref name="child"/>'s change notifications. /// </summary> /// <param name="child">The nested <see cref="SettingsNode"/>.</param> protected internal void AddSettingsChild(SettingsNode child) { ValidateChildForAssignment(child); child.Parent = this; }