////////////////////////////////////////////////////////////////////// /// <summary>parses an xml node to create an Comments object</summary> /// <param name="node">comments node</param> /// <returns> the created Comments object</returns> ////////////////////////////////////////////////////////////////////// public static Comments ParseComments(XmlNode node) { Tracing.TraceCall(); Comments comments = null; Tracing.Assert(node != null, "node should not be null"); if (node == null) { throw new ArgumentNullException("node"); } object localname = node.LocalName; if (localname.Equals(GDataParserNameTable.XmlCommentsElement)) { comments = new Comments(); if (node.HasChildNodes) { XmlNode commentsChild = node.FirstChild; while (commentsChild != null && commentsChild is XmlElement) { if (commentsChild.LocalName == GDataParserNameTable.XmlFeedLinkElement && commentsChild.NamespaceURI == BaseNameTable.gNamespace) { if (comments.FeedLink == null) { comments.FeedLink = FeedLink.ParseFeedLink(commentsChild); } else { throw new ArgumentException("Only one feedLink is allowed inside the gd:comments"); } } commentsChild = commentsChild.NextSibling; } } } if (comments.FeedLink == null) { throw new ArgumentException("gd:comments/gd:feedLink is required."); } return comments; }
////////////////////////////////////////////////////////////////////// /// <summary>Parses an xml node to create a Where object.</summary> /// <param name="node">the node to parse node</param> /// <param name="parser">the xml parser to use if we need to dive deeper</param> /// <returns>the created Where object</returns> ////////////////////////////////////////////////////////////////////// public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) { Tracing.TraceCall(); Comments comments = null; if (node != null) { object localname = node.LocalName; if (!localname.Equals(this.XmlName) || !node.NamespaceURI.Equals(this.XmlNameSpace)) { return null; } } comments = new Comments(); if (node != null) { if (node.HasChildNodes) { XmlNode commentsChild = node.FirstChild; while (commentsChild != null && commentsChild is XmlElement) { if (commentsChild.LocalName == GDataParserNameTable.XmlFeedLinkElement && commentsChild.NamespaceURI == BaseNameTable.gNamespace) { if (comments.FeedLink == null) { comments.FeedLink = FeedLink.ParseFeedLink(commentsChild); } else { throw new ArgumentException("Only one feedLink is allowed inside the gd:comments"); } } commentsChild = commentsChild.NextSibling; } } } return comments; }