Пример #1
0
        public AtomEntryBase Read(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            AtomEntryBase entry = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("entry"))
                {
                    entry = new AtomEntry();
                    VisitEntryElement(reader, entry as AtomEntry);
                }

                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("feed"))
                {
                    entry = new AtomFeed();
                    VisitFeedElement(reader, entry as AtomFeed);
                }
            }

            return entry;
        }
Пример #2
0
        private static void VisitFeedElement(XmlReader reader, AtomFeed feed)
        {
            while (reader.Read())
            {
                TryReadCommonProperties(reader, feed);

                if (reader.NodeType != XmlNodeType.Element)
                    continue;

                switch (reader.Name)
                {
                    case "subtitle":
                        VisitTextConstruct(reader, feed, "subtitle", (c, e) => e.AddSubtitle(c));
                        break;
                    case "rights":
                        VisitTextConstruct(reader, feed, "rights", (c, e) => e.AddRights(c));
                        break;
                    case "icon":
                        VisitIconElement(reader, feed);
                        break;
                    case "logo":
                        VisitLogoElement(reader, feed);
                        break;
                    case "generator":
                        VisitGeneratorElement(reader, feed);
                        break;
                    case "entry":
                        VisitEntryElement(reader, feed);
                        break;
                }
            }
        }
Пример #3
0
 private static void VisitEntryElement(XmlReader reader, AtomFeed feed)
 {
     var entry = new AtomEntry();
     VisitEntryElement(reader, entry);
     feed.AddEntry(entry);
 }