/// <summary> /// Modifies the <see cref="AtomFeed"/> optional 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 FillFeedOptionals(AtomFeed feed, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { Guard.ArgumentNotNull(feed, "feed"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); XPathNavigator generatorNavigator = source.SelectSingleNode("atom:generator", manager); XPathNavigator copyrightNavigator = source.SelectSingleNode("atom:copyright", manager); XPathNavigator taglineNavigator = source.SelectSingleNode("atom:tagline", manager); if (generatorNavigator != null) { feed.Generator = Atom03SyndicationResourceAdapter.CreateGenerator(generatorNavigator, manager, settings); } if (copyrightNavigator != null) { feed.Rights = Atom03SyndicationResourceAdapter.CreateTextContent(copyrightNavigator, manager, settings); } if (taglineNavigator != null) { feed.Subtitle = Atom03SyndicationResourceAdapter.CreateTextContent(taglineNavigator, manager, settings); } }
/// <summary> /// Modifies the <see cref="AtomEntry"/> optional 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 FillEntryOptionals(AtomEntry entry, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { Guard.ArgumentNotNull(entry, "entry"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); XPathNavigator contentNavigator = source.SelectSingleNode("atom:content", manager); XPathNavigator createdNavigator = source.SelectSingleNode("atom:created", manager); XPathNavigator summaryNavigator = source.SelectSingleNode("atom:summary", manager); if (contentNavigator != null) { entry.Content = Atom03SyndicationResourceAdapter.CreateContent(contentNavigator, manager, settings); } if (createdNavigator != null) { DateTime publishedOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(createdNavigator.Value, out publishedOn)) { entry.PublishedOn = publishedOn; } } if (summaryNavigator != null) { entry.Summary = Atom03SyndicationResourceAdapter.CreateTextContent(summaryNavigator, manager, settings); } }
/// <summary> /// Modifies the <see cref="AtomFeed"/> to match the data source. /// </summary> /// <param name="resource">The <see cref="AtomFeed"/> to be filled.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> public void Fill(AtomFeed resource) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(resource, "resource"); //------------------------------------------------------------ // Create namespace resolver //------------------------------------------------------------ XmlNamespaceManager manager = Atom03SyndicationResourceAdapter.CreateNamespaceManager(this.Navigator.NameTable); //------------------------------------------------------------ // Attempt to fill syndication resource //------------------------------------------------------------ XPathNavigator feedNavigator = this.Navigator.SelectSingleNode("atom:feed", manager); if (feedNavigator != null) { AtomUtility.FillCommonObjectAttributes(resource, feedNavigator); XPathNavigator idNavigator = feedNavigator.SelectSingleNode("atom:id", manager); XPathNavigator titleNavigator = feedNavigator.SelectSingleNode("atom:title", manager); XPathNavigator modifiedNavigator = feedNavigator.SelectSingleNode("atom:modified", manager); if (idNavigator != null) { resource.Id = new AtomId(); resource.Id.Load(idNavigator, this.Settings); } if (titleNavigator != null) { resource.Title = Atom03SyndicationResourceAdapter.CreateTextContent(titleNavigator, manager, this.Settings); } if (modifiedNavigator != null) { DateTime updatedOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(modifiedNavigator.Value, out updatedOn)) { resource.UpdatedOn = updatedOn; } } Atom03SyndicationResourceAdapter.FillFeedOptionals(resource, feedNavigator, manager, this.Settings); Atom03SyndicationResourceAdapter.FillFeedCollections(resource, feedNavigator, manager, this.Settings); SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(feedNavigator, this.Settings); adapter.Fill(resource, manager); } }
/// <summary> /// Modifies the <see cref="AtomEntry"/> 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 FillEntry(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 fill syndication resource //------------------------------------------------------------ AtomUtility.FillCommonObjectAttributes(entry, source); XPathNavigator idNavigator = source.SelectSingleNode("atom:id", manager); XPathNavigator titleNavigator = source.SelectSingleNode("atom:title", manager); XPathNavigator modifiedNavigator = source.SelectSingleNode("atom:modified", manager); if (idNavigator != null) { entry.Id = new AtomId(); entry.Id.Load(idNavigator, settings); } if (titleNavigator != null) { entry.Title = Atom03SyndicationResourceAdapter.CreateTextContent(titleNavigator, manager, settings); } if (modifiedNavigator != null) { DateTime updatedOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(modifiedNavigator.Value, out updatedOn)) { entry.UpdatedOn = updatedOn; } } Atom03SyndicationResourceAdapter.FillEntryOptionals(entry, source, manager, settings); Atom03SyndicationResourceAdapter.FillEntryCollections(entry, source, manager, settings); SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(source, settings); adapter.Fill(entry, manager); }