private void ReadDocument(XmlReader reader) { CreateInlineCategoriesDelegate inlineCategoriesFactory = null; CreateReferencedCategoriesDelegate referencedCategoriesFactory = null; try { SyndicationFeedFormatter.MoveToStartElement(reader); if (inlineCategoriesFactory == null) { inlineCategoriesFactory = () => this.CreateInlineCategoriesDocument(); } if (referencedCategoriesFactory == null) { referencedCategoriesFactory = () => this.CreateReferencedCategoriesDocument(); } this.SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null, inlineCategoriesFactory, referencedCategoriesFactory, this.Version, this.preserveElementExtensions, this.preserveAttributeExtensions, this.maxExtensionSize)); } catch (FormatException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, "ErrorParsingDocument"), exception)); } catch (ArgumentException exception2) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, "ErrorParsingDocument"), exception2)); } }
internal static CategoriesDocument ReadCategories(XmlReader reader, Uri baseUri, CreateInlineCategoriesDelegate inlineCategoriesFactory, CreateReferencedCategoriesDelegate referencedCategoriesFactory, string version, bool preserveElementExtensions, bool preserveAttributeExtensions, int maxExtensionSize) { string attribute = reader.GetAttribute("href", string.Empty); if (string.IsNullOrEmpty(attribute)) { InlineCategoriesDocument inlineCategories = inlineCategoriesFactory(); ReadInlineCategories(reader, inlineCategories, baseUri, version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return inlineCategories; } ReferencedCategoriesDocument referencedCategories = referencedCategoriesFactory(); ReadReferencedCategories(reader, referencedCategories, baseUri, new Uri(attribute, UriKind.RelativeOrAbsolute), version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return referencedCategories; }
internal static async Task <CategoriesDocument> ReadCategories(XmlReaderWrapper reader, Uri baseUri, CreateInlineCategoriesDelegate inlineCategoriesFactory, CreateReferencedCategoriesDelegate referencedCategoriesFactory, string version, bool preserveElementExtensions, bool preserveAttributeExtensions, int maxExtensionSize) { string link = reader.GetAttribute(App10Constants.Href, string.Empty); if (string.IsNullOrEmpty(link)) { InlineCategoriesDocument inlineCategories = inlineCategoriesFactory(); await ReadInlineCategoriesAsync(reader, inlineCategories, baseUri, version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return(inlineCategories); } else { ReferencedCategoriesDocument referencedCategories = referencedCategoriesFactory(); await ReadReferencedCategoriesAsync(reader, referencedCategories, baseUri, new Uri(link, UriKind.RelativeOrAbsolute), version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return(referencedCategories); } }
internal static CategoriesDocument ReadCategories(XmlReader reader, Uri baseUri, CreateInlineCategoriesDelegate inlineCategoriesFactory, CreateReferencedCategoriesDelegate referencedCategoriesFactory, string version, int maxExtensionSize) { string link = reader.GetAttribute(App10Constants.Href, string.Empty); if (string.IsNullOrEmpty(link)) { InlineCategoriesDocument inlineCategories = inlineCategoriesFactory(); ReadInlineCategories(reader, inlineCategories, baseUri, version, maxExtensionSize); return(inlineCategories); } else { ReferencedCategoriesDocument referencedCategories = referencedCategoriesFactory(); ReadReferencedCategories(reader, referencedCategories, baseUri, new Uri(link, UriKind.RelativeOrAbsolute), version, maxExtensionSize); return(referencedCategories); } }
private ResourceCollectionInfo ReadCollection(XmlReader reader, Workspace workspace) { CreateInlineCategoriesDelegate inlineCategoriesFactory = null; CreateReferencedCategoriesDelegate referencedCategoriesFactory = null; ResourceCollectionInfo result = ServiceDocumentFormatter.CreateCollection(workspace); result.BaseUri = workspace.BaseUri; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if ((reader.LocalName == "base") && (reader.NamespaceURI == "http://www.w3.org/XML/1998/namespace")) { result.BaseUri = FeedUtils.CombineXmlBase(result.BaseUri, reader.Value); } else { if ((reader.LocalName == "href") && (reader.NamespaceURI == string.Empty)) { result.Link = new Uri(reader.Value, UriKind.RelativeOrAbsolute); 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, result, this.Version)) { if (this.preserveAttributeExtensions) { result.AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value); continue; } SyndicationFeedFormatter.TraceSyndicationElementIgnoredOnRead(reader); } } } } } XmlBuffer buffer = null; XmlDictionaryWriter extWriter = null; reader.ReadStartElement(); try { while (reader.IsStartElement()) { if (reader.IsStartElement("title", "http://www.w3.org/2005/Atom")) { result.Title = Atom10FeedFormatter.ReadTextContentFrom(reader, "//app:service/app:workspace/app:collection/atom:title[@type]", this.preserveAttributeExtensions); } else { if (reader.IsStartElement("categories", "http://www.w3.org/2007/app")) { if (inlineCategoriesFactory == null) { inlineCategoriesFactory = () => ServiceDocumentFormatter.CreateInlineCategories(result); } if (referencedCategoriesFactory == null) { referencedCategoriesFactory = () => ServiceDocumentFormatter.CreateReferencedCategories(result); } result.Categories.Add(ReadCategories(reader, result.BaseUri, inlineCategoriesFactory, referencedCategoriesFactory, this.Version, this.preserveElementExtensions, this.preserveAttributeExtensions, this.maxExtensionSize)); continue; } if (reader.IsStartElement("accept", "http://www.w3.org/2007/app")) { result.Accepts.Add(reader.ReadElementString()); } else if (!ServiceDocumentFormatter.TryParseElement(reader, result, this.Version)) { if (this.preserveElementExtensions) { SyndicationFeedFormatter.CreateBufferIfRequiredAndWriteNode(ref buffer, ref extWriter, reader, this.maxExtensionSize); continue; } SyndicationFeedFormatter.TraceSyndicationElementIgnoredOnRead(reader); reader.Skip(); } } } ServiceDocumentFormatter.LoadElementExtensions(buffer, extWriter, result); } finally { if (extWriter != null) { extWriter.Close(); } } reader.ReadEndElement(); return(result); }
internal static CategoriesDocument ReadCategories(XmlReader reader, Uri baseUri, CreateInlineCategoriesDelegate inlineCategoriesFactory, CreateReferencedCategoriesDelegate referencedCategoriesFactory, string version, bool preserveElementExtensions, bool preserveAttributeExtensions, int maxExtensionSize) { string attribute = reader.GetAttribute("href", string.Empty); if (string.IsNullOrEmpty(attribute)) { InlineCategoriesDocument inlineCategories = inlineCategoriesFactory(); ReadInlineCategories(reader, inlineCategories, baseUri, version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return(inlineCategories); } ReferencedCategoriesDocument referencedCategories = referencedCategoriesFactory(); ReadReferencedCategories(reader, referencedCategories, baseUri, new Uri(attribute, UriKind.RelativeOrAbsolute), version, preserveElementExtensions, preserveAttributeExtensions, maxExtensionSize); return(referencedCategories); }