/// <summary> /// Initializes the supplied <see cref="RssChannel"/> collection entities using the specified <see cref="XPathNavigator"/> and <see cref="XmlNamespaceManager"/>. /// </summary> /// <param name="channel">The <see cref="RssChannel"/> to be filled.</param> /// <param name="navigator">The <see cref="XPathNavigator"/> used to navigate the channel XML data.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> object used to configure the load operation.</param> /// <exception cref="ArgumentNullException">The <paramref name="channel"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="navigator"/> 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 FillChannelCollections(RssChannel channel, XPathNavigator navigator, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { Guard.ArgumentNotNull(channel, "channel"); Guard.ArgumentNotNull(navigator, "navigator"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); XPathNodeIterator skipDaysIterator = navigator.Select("skipDays/day", manager); XPathNodeIterator skipHoursIterator = navigator.Select("skipHours/hour", manager); XPathNodeIterator itemIterator = navigator.Select("item", manager); if (skipDaysIterator != null && skipDaysIterator.Count > 0) { while (skipDaysIterator.MoveNext()) { if (!String.IsNullOrEmpty(skipDaysIterator.Current.Value)) { try { DayOfWeek day = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), skipDaysIterator.Current.Value, true); if (!channel.SkipDays.Contains(day)) { channel.SkipDays.Add(day); } } catch (ArgumentException) { System.Diagnostics.Trace.TraceWarning("Rss092SyndicationResourceAdapter unable to determine DayOfWeek with a name of {0}.", skipDaysIterator.Current.Value); } } } } if (skipHoursIterator != null && skipHoursIterator.Count > 0) { while (skipHoursIterator.MoveNext()) { int hour; if (Int32.TryParse(skipHoursIterator.Current.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out hour)) { hour = hour - 1; // Convert to zero-based range if (!channel.SkipHours.Contains(hour) && (hour >= 0 && hour <= 23)) { channel.SkipHours.Add(hour); } else { System.Diagnostics.Trace.TraceWarning("Rss092SyndicationResourceAdapter unable to add duplicate or out-of-range skip hour with a value of {0}.", hour); } } } } if (itemIterator != null && itemIterator.Count > 0) { int counter = 0; while (itemIterator.MoveNext()) { RssItem item = new RssItem(); counter++; if (settings.RetrievalLimit != 0 && counter > settings.RetrievalLimit) { break; } Rss092SyndicationResourceAdapter.FillItem(item, itemIterator.Current, manager, settings); ((Collection <RssItem>)channel.Items).Add(item); } } }