Example #1
0
        /////////////////////////////////////////////////////////////////////////////


        #region EntryLink Parser
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses an xml node to create an EntryLink object</summary>
        /// <param name="node">entrylink node</param>
        /// <param name="parser">AtomFeedParser to use</param>
        /// <returns> the created EntryLink object</returns>
        //////////////////////////////////////////////////////////////////////
        public static EntryLink ParseEntryLink(XmlNode node, AtomFeedParser parser)
        {
            //Tracing.TraceCall();
            EntryLink link = 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.XmlEntryLinkElement))
            {
                link = new EntryLink();
                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeHref] != null)
                    {
                        link.Href = node.Attributes[GDataParserNameTable.XmlAttributeHref].Value;
                    }

                    if (node.Attributes[GDataParserNameTable.XmlAttributeReadOnly] != null)
                    {
                        link.ReadOnly = node.Attributes[GDataParserNameTable.XmlAttributeReadOnly].Value.Equals(Utilities.XSDTrue);
                    }

                    if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null)
                    {
                        link.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value;
                    }
                }

                if (node.HasChildNodes)
                {
                    XmlNode entryChild = node.FirstChild;

                    while (entryChild != null && entryChild is XmlElement)
                    {
                        if (entryChild.LocalName == AtomParserNameTable.XmlAtomEntryElement &&
                            entryChild.NamespaceURI == BaseNameTable.NSAtom)
                        {
                            if (link.Entry == null)
                            {
                                XmlReader reader = new XmlNodeReader(entryChild);
                                // move the reader to the first node
                                reader.Read();
                                AtomFeedParser p = new AtomFeedParser();
                                p.NewAtomEntry += new FeedParserEventHandler(link.OnParsedNewEntry);
                                p.ParseEntry(reader);
                            }
                            else
                            {
                                throw new ArgumentException("Only one entry is allowed inside the g:entryLink");
                            }
                        }
                        entryChild = entryChild.NextSibling;
                    }
                }
            }

            return(link);
        }
Example #2
0
 /// <summary>
 /// factory method to create an instance of a batchinterrupt during parsing
 /// </summary>
 /// <param name="node">the xmlnode that is going to be parsed</param>
 /// <param name="parser">the feedparser that is used right now</param>
 /// <returns></returns>
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     return(EntryLink.ParseEntryLink(node, parser));
 }