/// <summary> /// Modifies the <see cref="AtomEntry"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source. /// </summary> /// <param name="entry">The <see cref="AtomEntry"/> to be filled.</param> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents an Atom 0.3 element. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="entry"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception> private static void FillEntryCollections(AtomEntry entry, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(entry, "entry"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ XPathNodeIterator authorIterator = source.Select("atom:author", manager); XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager); XPathNodeIterator linkIterator = source.Select("atom:link", manager); if (authorIterator != null && authorIterator.Count > 0) { while (authorIterator.MoveNext()) { AtomPersonConstruct author = Atom03SyndicationResourceAdapter.CreatePerson(authorIterator.Current, manager, settings); entry.Authors.Add(author); } } if (contributorIterator != null && contributorIterator.Count > 0) { while (contributorIterator.MoveNext()) { AtomPersonConstruct contributor = Atom03SyndicationResourceAdapter.CreatePerson(contributorIterator.Current, manager, settings); entry.Contributors.Add(contributor); } } if (linkIterator != null && linkIterator.Count > 0) { while (linkIterator.MoveNext()) { AtomLink link = new AtomLink(); if (link.Load(linkIterator.Current, settings)) { entry.Links.Add(link); } } } }
/// <summary> /// Modifies the <see cref="AtomFeed"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source. /// </summary> /// <param name="feed">The <see cref="AtomFeed"/> to be filled.</param> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomFeed"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="feed"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception> private static void FillFeedCollections(AtomFeed feed, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { Guard.ArgumentNotNull(feed, "feed"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); XPathNodeIterator authorIterator = source.Select("atom:author", manager); XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager); XPathNodeIterator linkIterator = source.Select("atom:link", manager); XPathNodeIterator entryIterator = source.Select("atom:entry", manager); if (authorIterator != null && authorIterator.Count > 0) { while (authorIterator.MoveNext()) { AtomPersonConstruct author = Atom03SyndicationResourceAdapter.CreatePerson(authorIterator.Current, manager, settings); feed.Authors.Add(author); } } if (contributorIterator != null && contributorIterator.Count > 0) { while (contributorIterator.MoveNext()) { AtomPersonConstruct contributor = Atom03SyndicationResourceAdapter.CreatePerson(contributorIterator.Current, manager, settings); feed.Contributors.Add(contributor); } } if (entryIterator != null && entryIterator.Count > 0) { int counter = 0; while (entryIterator.MoveNext()) { AtomEntry entry = new AtomEntry(); counter++; Atom03SyndicationResourceAdapter.FillEntry(entry, entryIterator.Current, manager, settings); if (settings.RetrievalLimit != 0 && counter > settings.RetrievalLimit) { break; } ((Collection <AtomEntry>)feed.Entries).Add(entry); } } if (linkIterator != null && linkIterator.Count > 0) { while (linkIterator.MoveNext()) { AtomLink link = new AtomLink(); if (link.Load(linkIterator.Current, settings)) { feed.Links.Add(link); } } } }