// Constructor
        internal XmlDiffShrankNode(XmlDiffNode firstNode, XmlDiffNode lastNode) : base(-1)
        {
            Debug.Assert(firstNode != null);
            Debug.Assert(lastNode != null);
            Debug.Assert(firstNode.Position <= lastNode.Position);
            Debug.Assert(firstNode.NodeType != XmlDiffNodeType.Attribute ||
                         (firstNode.NodeType == XmlDiffNodeType.Attribute && firstNode == lastNode));

            _firstNode          = firstNode;
            _lastNode           = lastNode;
            _matchingShrankNode = null;

            // hash value
            XmlDiffNode curNode = firstNode;

            for (;;)
            {
                _hashValue += (_hashValue << 7) + curNode.HashValue;
                if (curNode == lastNode)
                {
                    break;
                }
                curNode = curNode._nextSibling;
            }

            _localAddress = DiffgramOperation.GetRelativeAddressOfNodeset(_firstNode, _lastNode);
        }
Exemple #2
0
// Constructor
        internal XmlDiffShrankNode(XmlDiffNode firstNode, XmlDiffNode lastNode, ulong hashValue) : base(-1)
        {
            Debug.Assert(firstNode != null);
            Debug.Assert(lastNode != null);
            Debug.Assert(firstNode.Position <= lastNode.Position);
            Debug.Assert(firstNode.NodeType != XmlDiffNodeType.Attribute ||
                         (firstNode.NodeType == XmlDiffNodeType.Attribute && firstNode == lastNode));

            _firstNode          = firstNode;
            _lastNode           = lastNode;
            _matchingShrankNode = null;

            _hashValue    = hashValue;
            _localAddress = DiffgramOperation.GetRelativeAddressOfNodeset(_firstNode, _lastNode);
        }
Exemple #3
0
        private XmlDiffShrankNode ReplaceNodeIntervalWithShrankNode(
            XmlDiffNode firstNode,
            XmlDiffNode lastNode,
            XmlDiffNode previousSibling)
        {
            var xmlDiffShrankNode = new XmlDiffShrankNode(firstNode, lastNode);
            var parent            = firstNode._parent;

            if (previousSibling == null && firstNode != parent._firstChildNode)
            {
                previousSibling = parent._firstChildNode;
                while (previousSibling._nextSibling != firstNode)
                {
                    previousSibling = previousSibling._nextSibling;
                }
            }
            if (previousSibling == null)
            {
                xmlDiffShrankNode._nextSibling = parent._firstChildNode;
                parent._firstChildNode         = xmlDiffShrankNode;
            }
            else
            {
                xmlDiffShrankNode._nextSibling = previousSibling._nextSibling;
                previousSibling._nextSibling   = xmlDiffShrankNode;
            }
            xmlDiffShrankNode._parent = parent;
            var         num1 = 0;
            XmlDiffNode nextSibling;

            do
            {
                nextSibling = xmlDiffShrankNode._nextSibling;
                num1       += nextSibling.NodesCount;
                xmlDiffShrankNode._nextSibling = xmlDiffShrankNode._nextSibling._nextSibling;
            }while (nextSibling != lastNode);
            if (num1 > 1)
            {
                var num2 = num1 - 1;
                for (; parent != null; parent = parent._parent)
                {
                    parent.NodesCount -= num2;
                }
            }
            return(xmlDiffShrankNode);
        }
Exemple #4
0
        internal XmlDiffShrankNode(XmlDiffNode firstNode, XmlDiffNode lastNode)
            : base(-1)
        {
            this._firstNode          = firstNode;
            this._lastNode           = lastNode;
            this._matchingShrankNode = (XmlDiffShrankNode)null;
            var xmlDiffNode = firstNode;

            while (true)
            {
                this._hashValue += (this._hashValue << 7) + xmlDiffNode.HashValue;
                if (xmlDiffNode != lastNode)
                {
                    xmlDiffNode = xmlDiffNode._nextSibling;
                }
                else
                {
                    break;
                }
            }
            this._localAddress = DiffgramOperation.GetRelativeAddressOfNodeset(this._firstNode, this._lastNode);
        }
Exemple #5
0
	private XmlDiffShrankNode ReplaceNodeIntervalWithShrankNode( XmlDiffNode firstNode, 
		                                                         XmlDiffNode lastNode,
		                                                         XmlDiffNode previousSibling,
                                                                 ulong hashValue )
	{
		XmlDiffShrankNode shrankNode = new XmlDiffShrankNode( firstNode, lastNode, hashValue );
		XmlDiffParentNode parent = firstNode._parent;

		// find previous sibling node
		if ( previousSibling == null  &&
			 firstNode != parent._firstChildNode )
		{
			previousSibling = parent._firstChildNode;
			while ( previousSibling._nextSibling != firstNode )
				previousSibling = previousSibling._nextSibling;
		}

		// insert shrank node
		if ( previousSibling == null )
		{
			Debug.Assert( firstNode == parent._firstChildNode );

			shrankNode._nextSibling = parent._firstChildNode;
			parent._firstChildNode = shrankNode;
		}
		else
		{
			shrankNode._nextSibling = previousSibling._nextSibling;
			previousSibling._nextSibling = shrankNode;
		}
        shrankNode._parent = parent;

		// remove the node interval & count the total number of nodes
		XmlDiffNode tmpNode;
        int totalNodesCount = 0;
        do
        {
            tmpNode = shrankNode._nextSibling;
            totalNodesCount += tmpNode.NodesCount;
			shrankNode._nextSibling = shrankNode._nextSibling._nextSibling;

        } while ( tmpNode != lastNode );

        // adjust nodes count
        Debug.Assert( totalNodesCount > 0 );
        if ( totalNodesCount > 1 )
        {
            totalNodesCount--;
            while ( parent != null )
            {
                parent.NodesCount -= totalNodesCount;
                parent = parent._parent;
            }
        }

		return shrankNode;
	}
Exemple #6
0
        // Constructor
        internal XmlDiffShrankNode(  XmlDiffNode firstNode, XmlDiffNode lastNode, ulong hashValue )
            : base(-1)
        {
            Debug.Assert( firstNode != null );
            Debug.Assert( lastNode != null );
            Debug.Assert( firstNode.Position <= lastNode.Position );
            Debug.Assert( firstNode.NodeType != XmlDiffNodeType.Attribute ||
                      (firstNode.NodeType == XmlDiffNodeType.Attribute && firstNode == lastNode ) );

            _firstNode = firstNode;
            _lastNode = lastNode;
            _matchingShrankNode = null;

            _hashValue = hashValue;
            _localAddress = DiffgramOperation.GetRelativeAddressOfNodeset( _firstNode, _lastNode );
        }
        // Constructor
        internal XmlDiffShrankNode(  XmlDiffNode firstNode, XmlDiffNode lastNode )
            : base(-1)
        {
            Debug.Assert( firstNode != null );
            Debug.Assert( lastNode != null );
            Debug.Assert( firstNode.Position <= lastNode.Position );
            Debug.Assert( firstNode.NodeType != XmlDiffNodeType.Attribute ||
                      (firstNode.NodeType == XmlDiffNodeType.Attribute && firstNode == lastNode ) );

            _firstNode = firstNode;
            _lastNode = lastNode;
            _matchingShrankNode = null;

            // hash value
            XmlDiffNode curNode = firstNode;
            for (;;) {
            _hashValue += ( _hashValue << 7 ) + curNode.HashValue;
            if ( curNode == lastNode )
                break;
            curNode = curNode._nextSibling;
            }

            _localAddress = DiffgramOperation.GetRelativeAddressOfNodeset( _firstNode, _lastNode );
        }