/// <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(); } }