Beispiel #1
0
        internal AtomFeedMetadata ReadAtomSourceInEntryContent()
        {
            AtomFeedMetadata atomFeedMetadata = AtomMetadataReaderUtils.CreateNewAtomFeedMetadata();

            if (base.XmlReader.IsEmptyElement)
            {
                base.XmlReader.Read();
                return(atomFeedMetadata);
            }
            base.XmlReader.Read();
            while (base.XmlReader.NodeType != XmlNodeType.EndElement)
            {
                if (base.XmlReader.NodeType != XmlNodeType.Element)
                {
                    base.XmlReader.Skip();
                }
                else
                {
                    if (base.XmlReader.NamespaceEquals(this.AtomNamespace))
                    {
                        this.SourceMetadataDeserializer.ReadAtomElementAsFeedMetadata(atomFeedMetadata);
                        continue;
                    }
                    base.XmlReader.Skip();
                }
            }
            base.XmlReader.Read();
            return(atomFeedMetadata);
        }
        /// <summary>
        /// Reads the atom:source element in the entry content.
        /// </summary>
        /// <returns>The information in the source element as <see cref="AtomFeedMetadata"/>.</returns>
        /// <remarks>
        /// Pre-Condition:  XmlNodeType.Element (atom:source) - the atom:source element to read.
        /// Post-Condition: Any                               - the node after the atom:source which was read.
        /// </remarks>
        internal AtomFeedMetadata ReadAtomSourceInEntryContent()
        {
            DebugUtils.CheckNoExternalCallers();
            this.AssertXmlCondition(XmlNodeType.Element);
            Debug.Assert(
                this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace && this.XmlReader.LocalName == AtomConstants.AtomSourceElementName,
                "Only atom:source element can be read by this method.");

            AtomFeedMetadata atomFeedMetadata = AtomMetadataReaderUtils.CreateNewAtomFeedMetadata();

            if (this.XmlReader.IsEmptyElement)
            {
                // Advance reader past this element.
                this.XmlReader.Read();
                return(atomFeedMetadata);
            }

            // Read the start tag of the source element.
            this.XmlReader.Read();

            while (this.XmlReader.NodeType != XmlNodeType.EndElement)
            {
                if (this.XmlReader.NodeType != XmlNodeType.Element)
                {
                    Debug.Assert(this.XmlReader.NodeType != XmlNodeType.EndElement, "EndElement should have been handled already.");

                    // Skip everything but elements, including insignificant nodes, text nodes and CDATA nodes.
                    this.XmlReader.Skip();
                    continue;
                }

                if (this.XmlReader.NamespaceEquals(this.AtomNamespace))
                {
                    // Use a feed metadata deserializer to process this element and modify atomFeedMetadata appropriately.
                    this.SourceMetadataDeserializer.ReadAtomElementAsFeedMetadata(atomFeedMetadata);
                }
                else
                {
                    // Skip all elements not in the ATOM namespace.
                    this.XmlReader.Skip();
                }
            }

            // Advance the reader past the end tag of the source element.
            this.XmlReader.Read();

            return(atomFeedMetadata);
        }