/// <summary> /// Adds a node to the list of children of this node. /// </summary> public void AddChild( Node child ) { string childName = child.Name; if ( child == this ) throw new ArgumentException( string.Format( "Node '{0}' cannot be added as a child of itself.", childName ) ); if ( childNodes.ContainsKey( childName ) ) throw new ArgumentException( string.Format( "Node '{0}' already has a child node with the name '{1}'.", this.name, childName ) ); child.RemoveFromParent(); childNodes.Add( childName, child ); child.NotifyOfNewParent( this ); }