예제 #1
0
		protected virtual void InsertChildCore( INode newINode )
		{
			if ( ! newINode.IsRoot ) throw new ArgumentException( "Node is not a Root" );
			if (   newINode.IsTree ) throw new ArgumentException( "Node is a tree" );
			
			IncrementVersion();

			OnInserting( this, NodeTreeInsertOperation.Child, newINode );

			NodeTree newNode = GetNodeTree( newINode );

			newNode._Parent = this;
			newNode._Next = this._Child;
			this._Child = newNode;

			if ( newNode.Next != null )
			{
				NodeTree Next = GetNodeTree( newNode.Next );
				Next._Previous = newNode;
			}

			OnInserted( this, NodeTreeInsertOperation.Child, newINode );
		}
예제 #2
0
		// Load
		/// <summary>Initializes a new instance of the class during deserialization.</summary>
		/// <param name="info">The SerializationInfo populated with data.</param>
		/// <param name="context">The source for this serialization.</param>
		/// <remarks>
		/// <p>This method is called during deserialization.</p>
		/// <p>Do not call this method directly.</p>
		/// </remarks>
		protected NodeTree( SerializationInfo info, StreamingContext context )
		{
			int iVersion =            info.GetInt32( "NodeTreeVersion" );
			_Data        =            info.GetValue( "Data"        , typeof( object   ) );
			_Parent      = (NodeTree) info.GetValue( "Parent"      , typeof( NodeTree ) );
			_Previous    = (NodeTree) info.GetValue( "Previous"    , typeof( NodeTree ) );
			_Next        = (NodeTree) info.GetValue( "Next"        , typeof( NodeTree ) );
			_Child       = (NodeTree) info.GetValue( "Child"       , typeof( NodeTree ) );
		}
예제 #3
0
//-----------------------------------------------------------------------------

		protected virtual void InsertPreviousCore( INode newINode )
		{
			if (   this    .IsRoot ) throw new InvalidOperationException( "This is a Root" );
			if ( ! newINode.IsRoot ) throw new ArgumentException( "Node is not a Root" );
			if (   newINode.IsTree ) throw new ArgumentException( "Node is a tree" );

			IncrementVersion();

			OnInserting( this, NodeTreeInsertOperation.Previous, newINode );

			NodeTree newNode = GetNodeTree( newINode );

			newNode._Parent   = this._Parent;
			newNode._Previous = this._Previous;
			newNode._Next     = this;
			this._Previous    = newNode;

			if ( newNode.Previous != null )
			{
				NodeTree Previous = GetNodeTree( newNode.Previous );
				Previous._Next = newNode;
			}
			else // this is a first node
			{
				NodeTree Parent = GetNodeTree( newNode.Parent );
				Parent._Child = newNode;
			}

			OnInserted( this, NodeTreeInsertOperation.Previous, newINode );
		}
예제 #4
0
		public static ITree NewTree( Type dataType )
		{
			NodeTree n = new NodeTree();
			n._Data = new RootObject( dataType );
			return n;
		}
예제 #5
0
		public void Clear()
		{
			if ( ! this.IsRoot ) throw new InvalidOperationException( "This is not a Root" );
			if ( ! this.IsTree ) throw new InvalidOperationException( "This is not a tree" );

			OnClearing( this );

			_Child = null;

			OnCleared( this );
		}
예제 #6
0
		private void CopyChildNodes( INode oldNode, NodeTree newNode, bool bDeepCopy )
		{
			NodeTree previousNewChildNode = null;

			for ( INode oldChildNode = oldNode.Child ; oldChildNode != null ; oldChildNode = oldChildNode.Next )
			{
				NodeTree newChildNode = CreateNode();

				if ( ! bDeepCopy )
					newChildNode._Data = oldChildNode.Data;
				else
					newChildNode._Data = DeepCopyData( oldChildNode.Data );

//				if ( ! bDeepCopy )
//					OnCopying( oldChildNode, newChildNode );
//				else
//					OnDeepCopying( oldChildNode, newChildNode );

				if ( oldChildNode.Previous == null ) newNode._Child = newChildNode;
					
				newChildNode._Parent = newNode;
				newChildNode._Previous = previousNewChildNode;
				if ( previousNewChildNode != null ) previousNewChildNode._Next = newChildNode;
					
//				if ( ! bDeepCopy )
//					OnCopied( oldChildNode, newChildNode );
//				else
//					OnDeepCopied( oldChildNode, newChildNode );

				CopyChildNodes( oldChildNode, newChildNode, bDeepCopy );

				previousNewChildNode = newChildNode;
			}
		}
예제 #7
0
//-----------------------------------------------------------------------------
		
		protected virtual NodeTree CutCore()
		{
			if ( this.IsRoot ) throw new InvalidOperationException( "This is a Root" );

			IncrementVersion();

			OnCutting( this );

			INode OldRoot = Root;

			if ( this._Next != null )
				this._Next._Previous = this._Previous;

			if ( this.Previous != null )
				this._Previous._Next = this._Next;
			else // this is a first node
			{
				Debug.Assert( Parent.Child == this );
				this._Parent._Child = this._Next;
				Debug.Assert( this.Next == null || this.Next.Previous == null );
			}

			this._Parent   = null;
			this._Previous = null;
			this._Next     = null;

			OnCutDone( OldRoot, this );

			return this;
		}
예제 #8
0
//-----------------------------------------------------------------------------

		private NodeTree BoxInTree( Type dataType, NodeTree node )
		{
			if ( ! node.IsRoot ) throw new ArgumentException( "Node is not a Root" );
			if (   node.IsTree ) throw new ArgumentException( "Node is a tree"     );
			
			NodeTree tree = CreateTree( dataType );

			tree.AddChildCore( node );

			return tree;
		}