private static void ReadInlineCategories(XmlReader reader, InlineCategoriesDocument inlineCategories, Uri baseUri, string version, int maxExtensionSize) { inlineCategories.BaseUri = baseUri; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if (reader.LocalName == "base" && reader.NamespaceURI == Atom10FeedFormatter.XmlNs) { inlineCategories.BaseUri = FeedUtils.CombineXmlBase(inlineCategories.BaseUri, reader.Value); } else if (reader.LocalName == "lang" && reader.NamespaceURI == Atom10FeedFormatter.XmlNs) { inlineCategories.Language = reader.Value; } else if (reader.LocalName == App10Constants.Fixed && reader.NamespaceURI == string.Empty) { inlineCategories.IsFixed = (reader.Value == "yes"); } else if (reader.LocalName == Atom10Constants.SchemeTag && reader.NamespaceURI == string.Empty) { inlineCategories.Scheme = reader.Value; } else { string ns = reader.NamespaceURI; string name = reader.LocalName; if (FeedUtils.IsXmlns(name, ns) || FeedUtils.IsXmlSchemaType(name, ns)) { continue; } string val = reader.Value; if (!TryParseAttribute(name, ns, val, inlineCategories, version)) { inlineCategories.AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value); } } } } SyndicationFeedFormatter.MoveToStartElement(reader); bool isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement(); if (!isEmptyElement) { XmlBuffer buffer = null; XmlDictionaryWriter extWriter = null; try { while (reader.IsStartElement()) { if (reader.IsStartElement(Atom10Constants.CategoryTag, Atom10Constants.Atom10Namespace)) { SyndicationCategory category = CreateCategory(inlineCategories); Atom10FeedFormatter.ReadCategory(reader, category, version, preserveAttributeExtensions: true, preserveElementExtensions: true, maxExtensionSize); if (category.Scheme == null) { category.Scheme = inlineCategories.Scheme; } inlineCategories.Categories.Add(category); } else if (!TryParseElement(reader, inlineCategories, version)) { SyndicationFeedFormatter.CreateBufferIfRequiredAndWriteNode(ref buffer, ref extWriter, reader, maxExtensionSize); } } LoadElementExtensions(buffer, extWriter, inlineCategories); } finally { extWriter?.Close(); } reader.ReadEndElement(); } }
private static void ReadInlineCategories(XmlReader reader, InlineCategoriesDocument inlineCategories, Uri baseUri, string version, bool preserveElementExtensions, bool preserveAttributeExtensions, int maxExtensionSize) { inlineCategories.BaseUri = baseUri; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if ((reader.LocalName == "base") && (reader.NamespaceURI == "http://www.w3.org/XML/1998/namespace")) { inlineCategories.BaseUri = FeedUtils.CombineXmlBase(inlineCategories.BaseUri, reader.Value); } else { if ((reader.LocalName == "lang") && (reader.NamespaceURI == "http://www.w3.org/XML/1998/namespace")) { inlineCategories.Language = reader.Value; continue; } if ((reader.LocalName == "fixed") && (reader.NamespaceURI == string.Empty)) { inlineCategories.IsFixed = reader.Value == "yes"; continue; } if ((reader.LocalName == "scheme") && (reader.NamespaceURI == string.Empty)) { inlineCategories.Scheme = reader.Value; continue; } string namespaceURI = reader.NamespaceURI; string localName = reader.LocalName; if (!FeedUtils.IsXmlns(localName, namespaceURI) && !FeedUtils.IsXmlSchemaType(localName, namespaceURI)) { string str3 = reader.Value; if (!ServiceDocumentFormatter.TryParseAttribute(localName, namespaceURI, str3, inlineCategories, version)) { if (preserveAttributeExtensions) { inlineCategories.AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value); continue; } SyndicationFeedFormatter.TraceSyndicationElementIgnoredOnRead(reader); } } } } } SyndicationFeedFormatter.MoveToStartElement(reader); bool isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement(); if (!isEmptyElement) { XmlBuffer buffer = null; XmlDictionaryWriter extWriter = null; try { while (reader.IsStartElement()) { if (reader.IsStartElement("category", "http://www.w3.org/2005/Atom")) { SyndicationCategory category = ServiceDocumentFormatter.CreateCategory(inlineCategories); Atom10FeedFormatter.ReadCategory(reader, category, version, preserveAttributeExtensions, preserveElementExtensions, maxExtensionSize); if (category.Scheme == null) { category.Scheme = inlineCategories.Scheme; } inlineCategories.Categories.Add(category); } else if (!ServiceDocumentFormatter.TryParseElement(reader, inlineCategories, version)) { if (preserveElementExtensions) { SyndicationFeedFormatter.CreateBufferIfRequiredAndWriteNode(ref buffer, ref extWriter, reader, maxExtensionSize); continue; } SyndicationFeedFormatter.TraceSyndicationElementIgnoredOnRead(reader); reader.Skip(); } } ServiceDocumentFormatter.LoadElementExtensions(buffer, extWriter, inlineCategories); } finally { if (extWriter != null) { extWriter.Close(); } } reader.ReadEndElement(); } }