示例#1
0
        /// <summary>
        /// Add a child
        /// </summary>
        /// <param name="child">Node to add as a child</param>
        public void AddChild(Node child)
        {
            if (child == null) throw new ArgumentNullException("child");
            if (child._parentNode != null)
            {
                if (child._parentNode != this) throw new ArgumentException("", "child");

                return;
            }

            Childrens.Add(child);
            child.SetParent(this);
        }
示例#2
0
        /// <summary>
        /// Remove a child
        /// </summary>
        /// <param name="child">Child to remove</param>
        /// <returns></returns>
        public bool RemoveChild(Node child)
        {
            if(child._parentNode != this) throw new ArgumentException("", "child");

            Childrens.Remove(child);
            child.SetParent(null);

            return true;
        }