private void ReadCategoryElement(AtomFeedMetadata atomFeedMetadata) { AtomCategoryMetadata categoryMetadata = new AtomCategoryMetadata(); while (base.XmlReader.MoveToNextAttribute()) { string str; if (base.XmlReader.NamespaceEquals(this.EmptyNamespace) && ((str = base.XmlReader.LocalName) != null)) { if (!(str == "scheme")) { if (str == "term") { goto Label_0069; } if (str == "label") { goto Label_007C; } } else { categoryMetadata.Scheme = base.XmlReader.Value; } } continue; Label_0069: categoryMetadata.Term = base.XmlReader.Value; continue; Label_007C: categoryMetadata.Label = base.XmlReader.Value; } AtomMetadataReaderUtils.AddCategoryToFeedMetadata(atomFeedMetadata, categoryMetadata); base.XmlReader.Skip(); }
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); }
private void ReadContributorElement(IODataAtomReaderEntryState entryState, EpmTargetPathSegment epmTargetPathSegment) { if (this.ShouldReadCollectionElement(entryState.AtomEntryMetadata.Contributors.Any <AtomPersonMetadata>())) { AtomMetadataReaderUtils.AddContributorToEntryMetadata(entryState.AtomEntryMetadata, base.ReadAtomPersonConstruct(epmTargetPathSegment)); } else { base.XmlReader.Skip(); } }
/// <summary> /// Reads an atom:contributor element in a feed. /// </summary> /// <param name="atomFeedMetadata">The feed metadata to augment.</param> /// <remarks> /// Pre-Condition: XmlNodeType.Element (atom:contributor) - the atom:contributor element to read. /// Post-Condition: Any - the node after the atom:contributor element which was read. /// </remarks> private void ReadContributorElement(AtomFeedMetadata atomFeedMetadata) { this.AssertXmlCondition(XmlNodeType.Element); Debug.Assert( this.XmlReader.LocalName == AtomConstants.AtomContributorElementName && this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace, "Only atom:contributor elements can be read by this method."); AtomMetadataReaderUtils.AddContributorToFeedMetadata( atomFeedMetadata, this.ReadAtomPersonConstruct(null)); }
/// <summary> /// Reads an atom:link element into the Links collection of feed metadata (i.e., links that are not special to the OData protocol). /// </summary> /// <param name="atomFeedMetadata">The feed metadata to augment.</param> /// <remarks> /// Pre-Condition: XmlNodeType.Element (atom:link) - the atom:link element to read. /// Post-Condition: Any - the node after the atom:link element which was read. /// </remarks> private void ReadLinkElementIntoLinksCollection(AtomFeedMetadata atomFeedMetadata) { this.AssertXmlCondition(XmlNodeType.Element); Debug.Assert( this.XmlReader.LocalName == AtomConstants.AtomLinkElementName && this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace, "Only atom:link elements can be read by this method."); // By sending nulls to ReadAtomLinkElementInFeed(), the method will read and store values for href and rel from the wire (inside of using parameter overrides). AtomLinkMetadata linkMetadata = this.ReadAtomLinkElementInFeed(null, null); AtomMetadataReaderUtils.AddLinkToFeedMetadata(atomFeedMetadata, linkMetadata); }
/// <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); }
/// <summary> /// Reads a contributor element. /// </summary> /// <param name="entryState">The reader entry state for the entry being read.</param> /// <param name="epmTargetPathSegment">The EPM target path segment for the element to read, or null if no EPM for that element is defined.</param> /// <remarks> /// Pre-Condition: XmlNodeType.Element (atom:contributor) - the atom:contributor element to read. /// Post-Condition: Any - the node after the atom:contributor element which was read. /// </remarks> private void ReadContributorElement(IODataAtomReaderEntryState entryState, EpmTargetPathSegment epmTargetPathSegment) { Debug.Assert(entryState != null, "entryState != null"); this.AssertXmlCondition(XmlNodeType.Element); Debug.Assert( this.XmlReader.LocalName == AtomConstants.AtomContributorElementName && this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace, "Only atom:contributor elements can be read by this method."); if (this.ShouldReadCollectionElement(entryState.AtomEntryMetadata.Contributors.Any())) { AtomMetadataReaderUtils.AddContributorToEntryMetadata( entryState.AtomEntryMetadata, this.ReadAtomPersonConstruct(epmTargetPathSegment)); } else { this.XmlReader.Skip(); } }
/// <summary> /// Reads an atom:category element in a feed. /// </summary> /// <param name="atomFeedMetadata">The feed metadata to augment.</param> /// <remarks> /// Pre-Condition: XmlNodeType.Element (atom:category) - the atom:category element to read. /// Post-Condition: Any - the node after the atom:category which was read. /// </remarks> private void ReadCategoryElement(AtomFeedMetadata atomFeedMetadata) { DebugUtils.CheckNoExternalCallers(); this.AssertXmlCondition(XmlNodeType.Element); Debug.Assert( this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace && this.XmlReader.LocalName == AtomConstants.AtomCategoryElementName, "Only atom:category element can be read by this method."); AtomCategoryMetadata categoryMetadata = new AtomCategoryMetadata(); // Read the attributes while (this.XmlReader.MoveToNextAttribute()) { if (this.XmlReader.NamespaceEquals(this.EmptyNamespace)) { switch (this.XmlReader.LocalName) { case AtomConstants.AtomCategorySchemeAttributeName: categoryMetadata.Scheme = this.XmlReader.Value; break; case AtomConstants.AtomCategoryTermAttributeName: categoryMetadata.Term = this.XmlReader.Value; break; case AtomConstants.AtomCategoryLabelAttributeName: categoryMetadata.Label = this.XmlReader.Value; break; default: // Ignore all other attributes. break; } } } AtomMetadataReaderUtils.AddCategoryToFeedMetadata(atomFeedMetadata, categoryMetadata); // Skip the rest of the category element. this.XmlReader.Skip(); }
/// <summary> /// Reads the atom:category element in the entry content. /// </summary> /// <param name="entryState">The reader entry state for the entry being read.</param> /// <remarks> /// Pre-Condition: XmlNodeType.Element (atom:category) - the atom:category element to read. /// Post-Condition: Any - the node after the atom:category which was read. /// </remarks> internal void ReadAtomCategoryElementInEntryContent(IODataAtomReaderEntryState entryState) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(entryState != null, "entryState != null"); this.AssertXmlCondition(XmlNodeType.Element); Debug.Assert( this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace && this.XmlReader.LocalName == AtomConstants.AtomCategoryElementName, "Only atom:category element can be read by this method."); ODataEntityPropertyMappingCache cachedEpm = entryState.CachedEpm; EpmTargetPathSegment epmTargetPathSegment = null; if (cachedEpm != null) { epmTargetPathSegment = cachedEpm.EpmTargetTree.SyndicationRoot; } // Rough estimate if we will need the category for EPM - we can't tell for sure since we don't know the scheme value yet. bool hasCategoryEpm = epmTargetPathSegment != null && epmTargetPathSegment.SubSegments.Any(segment => string.CompareOrdinal(segment.SegmentName, AtomConstants.AtomCategoryElementName) == 0); // Read the attributes and create the category metadata regardless if we will need it or not. // We can do this since there's no validation done on any of the values and thus this operation will never fail. // If we then decide we don't need it, we can safely throw it away. if (this.ReadAtomMetadata || hasCategoryEpm) { AtomCategoryMetadata categoryMetadata = this.ReadAtomCategoryElement(); // No point in trying to figure out if we will need the category for EPM or not here. // Our EPM syndication reader must handle unneeded categories anyway (if ATOM metadata reading is on) // So instead of burning the cycles to compute if we need it, just store it anyway. AtomMetadataReaderUtils.AddCategoryToEntryMetadata(entryState.AtomEntryMetadata, categoryMetadata); } else { // Skip the element in any case (we only ever consume attributes on it anyway). this.XmlReader.Skip(); } }
internal void ReadAtomCategoryElementInEntryContent(IODataAtomReaderEntryState entryState) { ODataEntityPropertyMappingCache cachedEpm = entryState.CachedEpm; EpmTargetPathSegment syndicationRoot = null; if (cachedEpm != null) { syndicationRoot = cachedEpm.EpmTargetTree.SyndicationRoot; } if (syndicationRoot == null) { } bool flag = syndicationRoot.SubSegments.Any <EpmTargetPathSegment>(); if (base.ReadAtomMetadata || flag) { AtomCategoryMetadata categoryMetadata = this.ReadAtomCategoryElement(); AtomMetadataReaderUtils.AddCategoryToEntryMetadata(entryState.AtomEntryMetadata, categoryMetadata); } else { base.XmlReader.Skip(); } }
private void ReadLinkElementIntoLinksCollection(AtomFeedMetadata atomFeedMetadata) { AtomLinkMetadata linkMetadata = this.ReadAtomLinkElementInFeed(null, null); AtomMetadataReaderUtils.AddLinkToFeedMetadata(atomFeedMetadata, linkMetadata); }
private void ReadContributorElement(AtomFeedMetadata atomFeedMetadata) { AtomMetadataReaderUtils.AddContributorToFeedMetadata(atomFeedMetadata, base.ReadAtomPersonConstruct(null)); }