Ejemplo n.º 1
0
 internal static void ValidateChildForAssignment(SettingsNode child)
 {
     if (child.Parent != null)
     {
         throw new InvalidOperationException("Node already is a child of another node.");
     }
 }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
        /// <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;
        }
Ejemplo n.º 4
0
            public void Dispose()
            {
                if (this.settingsNode == null)
                {
                    throw new InvalidOperationException("Already disposed.");
                }

                var node = this.settingsNode;

                this.settingsNode = null;
                node.ExitEditScope();
            }
Ejemplo n.º 5
0
        /// <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();
            }
        }
Ejemplo n.º 6
0
 public EditScope(SettingsNode settingsNode)
 {
     this.settingsNode = settingsNode;
     this.settingsNode.EnterEditScope();
 }
Ejemplo n.º 7
0
 /// <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;
 }