Inheritance: IXmlDataVirtualNode
Exemplo n.º 1
0
 internal DataPointer( DataPointer pointer ) {
     this.doc = pointer.doc;
     this.node = pointer.node;
     this.column = pointer.column;
     this.fOnValue = pointer.fOnValue;
     this.bNeedFoliate = false;
     this._isInUse = true;
     AssertValid();
 }
Exemplo n.º 2
0
 internal DataPointer(DataPointer pointer)
 {
     _doc = pointer._doc;
     _node = pointer._node;
     _column = pointer._column;
     _fOnValue = pointer._fOnValue;
     _bNeedFoliate = false;
     _isInUse = true;
     AssertValid();
 }
Exemplo n.º 3
0
        internal void MoveTo( DataPointer pointer ) {
            AssertValid();
            // You should not move outside of this document
            Debug.Assert( node == this.doc || node.OwnerDocument == this.doc );

            this.doc = pointer.doc;
            this.node = pointer.node;
            this.column = pointer.column;
            this.fOnValue = pointer.fOnValue;
            AssertValid();
        }
Exemplo n.º 4
0
        internal void MoveTo(DataPointer pointer)
        {
            AssertValid();

            // You should not move outside of this document
            Debug.Assert(_node == _doc || _node.OwnerDocument == _doc);

            _doc = pointer._doc;
            _node = pointer._node;
            _column = pointer._column;
            _fOnValue = pointer._fOnValue;
            AssertValid();
        }
Exemplo n.º 5
0
        private static void WriteTo(DataPointer dp, XmlWriter w)
        {
            switch (dp.NodeType)
            {
            case XmlNodeType.Attribute:
                if (!dp.IsDefault)
                {
                    w.WriteStartAttribute(dp.Prefix, dp.LocalName, dp.NamespaceURI);

                    if (dp.MoveToFirstChild())
                    {
                        do
                        {
                            WriteTo(dp, w);
                        }while (dp.MoveToNextSibling());

                        dp.MoveToParent();
                    }

                    w.WriteEndAttribute();
                }
                break;

            case XmlNodeType.Element:
                WriteBoundElementTo(dp, w);
                break;

            case XmlNodeType.Text:
                w.WriteString(dp.Value);
                break;

            default:
                Debug.Assert(((IXmlDataVirtualNode)dp).IsOnColumn(null));
                if (dp.GetNode() != null)
                {
                    dp.GetNode().WriteTo(w);
                }
                break;
            }
        }
        private static void WriteBoundElementTo(DataPointer dp, XmlWriter w)
        {
            w.WriteStartElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
            int attributeCount = dp.AttributeCount;

            if (attributeCount > 0)
            {
                for (int i = 0; i < attributeCount; i++)
                {
                    dp.MoveToAttribute(i);
                    WriteTo(dp, w);
                    dp.MoveToOwnerElement();
                }
            }
            WriteBoundElementContentTo(dp, w);
            if (dp.IsEmptyElement)
            {
                w.WriteEndElement();
            }
            else
            {
                w.WriteFullEndElement();
            }
        }
Exemplo n.º 7
0
        private XmlNode CloneNode(DataPointer dp)
        {
            switch (dp.NodeType)
            {
                //for the nodes without value and have no children
                case XmlNodeType.DocumentFragment:
                    return CreateDocumentFragment();
                case XmlNodeType.DocumentType:
                    return CreateDocumentType(dp.Name, dp.PublicId, dp.SystemId, dp.InternalSubset);
                case XmlNodeType.XmlDeclaration:
                    return CreateXmlDeclaration(dp.Version, dp.Encoding, dp.Standalone);

                //for the nodes with value but no children
                case XmlNodeType.Text:
                    return CreateTextNode(dp.Value);
                case XmlNodeType.CDATA:
                    return CreateCDataSection(dp.Value);
                case XmlNodeType.ProcessingInstruction:
                    return CreateProcessingInstruction(dp.Name, dp.Value);
                case XmlNodeType.Comment:
                    return CreateComment(dp.Value);
                case XmlNodeType.Whitespace:
                    return CreateWhitespace(dp.Value);
                case XmlNodeType.SignificantWhitespace:
                    return CreateSignificantWhitespace(dp.Value);
                //for the nodes that don't have values, but might have children -- only clone the node and leave the children untouched
                case XmlNodeType.Element:
                    return CreateElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
                case XmlNodeType.Attribute:
                    return CreateAttribute(dp.Prefix, dp.LocalName, dp.NamespaceURI);
                case XmlNodeType.EntityReference:
                    return CreateEntityReference(dp.Name);
            }
            throw new InvalidOperationException(SR.Format(SR.DataDom_CloneNode, dp.NodeType.ToString()));
        }
Exemplo n.º 8
0
        public override XmlNode CloneNode(bool deep)
        {
            XmlDataDocument clone = (XmlDataDocument)(base.CloneNode(false));
            clone.Init(DataSet.Clone());

            clone._dataSet.EnforceConstraints = _dataSet.EnforceConstraints;
            Debug.Assert(clone.FirstChild == null);
            if (deep)
            {
                DataPointer dp = new DataPointer(this, this);
                try
                {
                    dp.AddPointer();
                    for (bool fMore = dp.MoveToFirstChild(); fMore; fMore = dp.MoveToNextSibling())
                    {
                        XmlNode cloneNode;
                        if (dp.NodeType == XmlNodeType.Element)
                            cloneNode = clone.CloneTree(dp);
                        else
                            cloneNode = clone.CloneNode(dp);
                        clone.AppendChild(cloneNode);
                    }
                }
                finally
                {
                    dp.SetNoLongerUse();
                }
            }

            return clone;
        }
Exemplo n.º 9
0
        private static void WriteTo( DataPointer dp, XmlWriter w ) {
            switch ( dp.NodeType ) {
                case XmlNodeType.Attribute:
                    if ( !dp.IsDefault ) {
                        w.WriteStartAttribute( dp.Prefix, dp.LocalName, dp.NamespaceURI );

                        if ( dp.MoveToFirstChild() ) {
                            do {
                                WriteTo( dp, w );
                            }
                            while ( dp.MoveToNextSibling() );

                            dp.MoveToParent();
                        }

                        w.WriteEndAttribute();
                    }
                    break;

                case XmlNodeType.Element:
                    WriteBoundElementTo( dp, w );
                    break;

                case XmlNodeType.Text:
                    w.WriteString(dp.Value);
                    break;

                default:
                    Debug.Assert( ((IXmlDataVirtualNode)dp).IsOnColumn( null ) );
                    if ( dp.GetNode() != null )
                        dp.GetNode().WriteTo( w );
                    break;
            }
        }
Exemplo n.º 10
0
        private static void WriteBoundElementContentTo( DataPointer dp, XmlWriter w ) {
            if ( !dp.IsEmptyElement && dp.MoveToFirstChild() ) {
                do {
                    WriteTo( dp, w );
                }
                while ( dp.MoveToNextSibling() );

                dp.MoveToParent();
            }
        }
Exemplo n.º 11
0
 private static void WriteBoundElementTo( DataPointer dp, XmlWriter w ) {
     Debug.Assert( dp.NodeType == XmlNodeType.Element );
     w.WriteStartElement( dp.Prefix, dp.LocalName, dp.NamespaceURI );
     int cAttr = dp.AttributeCount;
     if ( cAttr > 0 ) {
         for ( int iAttr = 0; iAttr < cAttr; iAttr++ ) {
             dp.MoveToAttribute( iAttr );
             WriteTo( dp, w );
             dp.MoveToOwnerElement();
         }
     }
     
     WriteBoundElementContentTo( dp, w );
     
     // Force long end tag when the elem is not empty, even if there are no children.
     if ( dp.IsEmptyElement )
         w.WriteEndElement();
     else
         w.WriteFullEndElement();
 }
 private void WriteRootBoundElementTo(DataPointer dp, XmlWriter w)
 {
     XmlDataDocument ownerDocument = (XmlDataDocument) this.OwnerDocument;
     w.WriteStartElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
     int attributeCount = dp.AttributeCount;
     bool flag = false;
     if (attributeCount > 0)
     {
         for (int i = 0; i < attributeCount; i++)
         {
             dp.MoveToAttribute(i);
             if ((dp.Prefix == "xmlns") && (dp.LocalName == "xsi"))
             {
                 flag = true;
             }
             WriteTo(dp, w);
             dp.MoveToOwnerElement();
         }
     }
     if ((!flag && ownerDocument.bLoadFromDataSet) && ownerDocument.bHasXSINIL)
     {
         w.WriteAttributeString("xmlns", "xsi", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance");
     }
     WriteBoundElementContentTo(dp, w);
     if (dp.IsEmptyElement)
     {
         w.WriteEndElement();
     }
     else
     {
         w.WriteFullEndElement();
     }
 }
 internal void MoveTo(DataPointer pointer)
 {
     this.doc = pointer.doc;
     this.node = pointer.node;
     this.column = pointer.column;
     this.fOnValue = pointer.fOnValue;
 }
Exemplo n.º 14
0
        public override void WriteTo(XmlWriter w)
        {
            DataPointer dp = new DataPointer((XmlDataDocument)OwnerDocument, this);

            WriteRootBoundElementTo(dp, w);
        }
        private static void WriteTo(DataPointer dp, XmlWriter w)
        {
            switch (dp.NodeType)
            {
                case XmlNodeType.Element:
                    WriteBoundElementTo(dp, w);
                    return;

                case XmlNodeType.Attribute:
                    if (dp.IsDefault)
                    {
                        break;
                    }
                    w.WriteStartAttribute(dp.Prefix, dp.LocalName, dp.NamespaceURI);
                    if (dp.MoveToFirstChild())
                    {
                        do
                        {
                            WriteTo(dp, w);
                        }
                        while (dp.MoveToNextSibling());
                        dp.MoveToParent();
                    }
                    w.WriteEndAttribute();
                    return;

                case XmlNodeType.Text:
                    w.WriteString(dp.Value);
                    return;

                default:
                    if (dp.GetNode() != null)
                    {
                        dp.GetNode().WriteTo(w);
                    }
                    break;
            }
        }
Exemplo n.º 16
0
        // This creates a tree and synchronize ROM w/ the created tree.
        // It requires the populated mode to be on - in case we are not in populated mode, it will make the XmlDataDocument be in populated mode.
        // It takes advantage of the fAssociateDataRow flag for populated mode, which allows creation of XmlBoundElement w/o associating DataRow objects.
        internal XmlNode CloneTree(DataPointer other)
        {
            EnsurePopulatedMode();

            bool oldIgnoreDataSetEvents = _ignoreDataSetEvents;
            bool oldIgnoreXmlEvents = _ignoreXmlEvents;
            bool oldFoliationEnabled = IsFoliationEnabled;
            bool oldAssociateDataRow = _fAssociateDataRow;

            // Caller should ensure that the EnforceConstraints == false. See 60486 for more info about why this was changed from DataSet.EnforceConstraints = false to an assert.
            Debug.Assert(DataSet.EnforceConstraints == false);
            XmlNode newNode;

            try
            {
                _ignoreDataSetEvents = true;
                _ignoreXmlEvents = true;
                IsFoliationEnabled = false;
                _fAssociateDataRow = false;

                // Create the diconnected tree based on the other navigator
                newNode = CloneTreeInternal(other);
                Debug.Assert(newNode != null);

                // Synchronize DataSet from XML
                LoadRows(null, newNode);
                SyncRows(null, newNode, false);
            }
            finally
            {
                _ignoreDataSetEvents = oldIgnoreDataSetEvents;
                _ignoreXmlEvents = oldIgnoreXmlEvents;
                IsFoliationEnabled = oldFoliationEnabled;
                _fAssociateDataRow = oldAssociateDataRow;
            }
            return newNode;
        }
Exemplo n.º 17
0
        private XmlNode CloneTreeInternal(DataPointer other)
        {
            Debug.Assert(_ignoreDataSetEvents == true);
            Debug.Assert(_ignoreXmlEvents == true);
            Debug.Assert(IsFoliationEnabled == false);

            // Create the diconnected tree based on the other navigator
            XmlNode newNode = CloneNode(other);

            DataPointer dp = new DataPointer(other);
            try
            {
                dp.AddPointer();
                if (newNode.NodeType == XmlNodeType.Element)
                {
                    int cAttributes = dp.AttributeCount;
                    for (int i = 0; i < cAttributes; i++)
                    {
                        dp.MoveToOwnerElement();
                        if (dp.MoveToAttribute(i))
                        {
                            newNode.Attributes.Append((XmlAttribute)CloneTreeInternal(dp));
                        }
                    }

                    dp.MoveTo(other);
                }

                for (bool fMore = dp.MoveToFirstChild(); fMore; fMore = dp.MoveToNextSibling())
                    newNode.AppendChild(CloneTreeInternal(dp));
            }
            finally
            {
                dp.SetNoLongerUse();
            }

            return newNode;
        }
Exemplo n.º 18
0
 public override void WriteTo( XmlWriter w ) {
     DataPointer dp = new DataPointer( (XmlDataDocument)OwnerDocument, this );            
     try {
         dp.AddPointer();
         WriteRootBoundElementTo( dp, w );
     }
     finally {
         dp.SetNoLongerUse();
     }
 }
Exemplo n.º 19
0
 private void WriteRootBoundElementTo(DataPointer dp, XmlWriter w) {            
     Debug.Assert( dp.NodeType == XmlNodeType.Element );
     XmlDataDocument doc = (XmlDataDocument)OwnerDocument;
     w.WriteStartElement( dp.Prefix, dp.LocalName, dp.NamespaceURI );            
     int cAttr = dp.AttributeCount;
     bool bHasXSI = false;
     if ( cAttr > 0 ) {
         for ( int iAttr = 0; iAttr < cAttr; iAttr++ ) {
             dp.MoveToAttribute( iAttr );
             if ( dp.Prefix == "xmlns" && dp.LocalName == XmlDataDocument.XSI )
                 bHasXSI = true;
             WriteTo( dp, w );
             dp.MoveToOwnerElement();
         }
     }
     
     if ( !bHasXSI && doc.bLoadFromDataSet && doc.bHasXSINIL ) 
         w.WriteAttributeString( "xmlns", "xsi", "http://www.w3.org/2000/xmlns/", Keywords.XSINS );
     
     
     WriteBoundElementContentTo( dp, w );
     
     // Force long end tag when the elem is not empty, even if there are no children.
     if ( dp.IsEmptyElement )
         w.WriteEndElement();
     else
         w.WriteFullEndElement();
 }
 private static void WriteBoundElementTo(DataPointer dp, XmlWriter w)
 {
     w.WriteStartElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
     int attributeCount = dp.AttributeCount;
     if (attributeCount > 0)
     {
         for (int i = 0; i < attributeCount; i++)
         {
             dp.MoveToAttribute(i);
             WriteTo(dp, w);
             dp.MoveToOwnerElement();
         }
     }
     WriteBoundElementContentTo(dp, w);
     if (dp.IsEmptyElement)
     {
         w.WriteEndElement();
     }
     else
     {
         w.WriteFullEndElement();
     }
 }