/// <summary> /// Modifies the <see cref="RssFeed"/> to match the data source. /// </summary> /// <param name="resource">The <see cref="RssFeed"/> to be filled.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> public void Fill(RssFeed resource) { Guard.ArgumentNotNull(resource, "resource"); XmlNamespaceManager manager = new XmlNamespaceManager(this.Navigator.NameTable); manager.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); manager.AddNamespace("rss", "http://purl.org/rss/1.0/"); XPathNavigator channelNavigator = this.Navigator.SelectSingleNode("rdf:RDF/rss:channel", manager); if (channelNavigator != null) { Rss10SyndicationResourceAdapter.FillChannel(resource.Channel, channelNavigator, manager, this.Settings); } XPathNavigator imageNavigator = this.Navigator.SelectSingleNode("rdf:RDF/rss:image", manager); if (imageNavigator != null) { resource.Channel.Image = new RssImage(); Rss10SyndicationResourceAdapter.FillImage(resource.Channel.Image, imageNavigator, manager, this.Settings); } XPathNavigator textInputNavigator = this.Navigator.SelectSingleNode("rdf:RDF/rss:textinput", manager); if (textInputNavigator != null) { resource.Channel.TextInput = new RssTextInput(); Rss10SyndicationResourceAdapter.FillTextInput(resource.Channel.TextInput, textInputNavigator, manager, this.Settings); } XPathNodeIterator itemIterator = this.Navigator.Select("rdf:RDF/rss:item", manager); if (itemIterator != null && itemIterator.Count > 0) { int counter = 0; while (itemIterator.MoveNext()) { RssItem item = new RssItem(); counter++; if (this.Settings.RetrievalLimit != 0 && counter > this.Settings.RetrievalLimit) { break; } XPathNavigator itemTitleNavigator = itemIterator.Current.SelectSingleNode("rss:title", manager); XPathNavigator itemLinkNavigator = itemIterator.Current.SelectSingleNode("rss:link", manager); XPathNavigator itemDescriptionNavigator = itemIterator.Current.SelectSingleNode("rss:description", manager); if (itemTitleNavigator != null) { item.Title = itemTitleNavigator.Value; } if (itemLinkNavigator != null) { Uri link; if (Uri.TryCreate(itemLinkNavigator.Value, UriKind.RelativeOrAbsolute, out link)) { item.Link = link; } } if (itemDescriptionNavigator != null) { item.Description = itemDescriptionNavigator.Value; } SyndicationExtensionAdapter itemExtensionAdapter = new SyndicationExtensionAdapter(itemIterator.Current, this.Settings); itemExtensionAdapter.Fill(item, manager); ((Collection <RssItem>)resource.Channel.Items).Add(item); } } SyndicationExtensionAdapter feedExtensionAdapter = new SyndicationExtensionAdapter(this.Navigator.SelectSingleNode("rdf:RDF", manager), this.Settings); feedExtensionAdapter.Fill(resource, manager); }