Ejemplo n.º 1
0
        /// <summary>
        /// Gets the feed items.
        /// </summary>
        /// <returns>
        /// The feed items.
        /// </returns>
        /// <param name='inputFeed'>
        /// Input feed.
        /// </param>
        /// <param name='since'>
        /// Since the given date time offset.
        /// </param>
        /// <param name='ignoreCerts'>
        /// Ignore invalid certificates
        /// </param>
        public static IEnumerable<FeedItem> GetItems(Feed inputFeed, DateTimeOffset? since, bool ignoreCerts)
        {
            if (ignoreCerts)
            {
                Logger.Write("Ignoring certificate errors");
                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback((a, b, c, d) => true);
            }

            using (XmlReader reader = XmlReader.Create(inputFeed.Source))
            {
                foreach (var item in GetItemsFromXml(since, reader))
                {
                    yield return item;
                }
            }
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public IEnumerable<FeedItem> GetItems(Feed feed, DateTimeOffset? since, bool ignoreCerts)
 {
     return SyndicationReader.GetItems(feed, since, ignoreCerts);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Print a new feed item
 /// </summary>
 /// <param name='format'>Output format</param>
 /// <param name='feed'>Feed to output</param>
 /// <param name='outputAction'>Output action</param>
 /// <param name='writer'>Xml writer</param>
 /// <param name='buffer'>Output buffer</param>
 /// <param name='serializer'>Serializer to use</param>
 private static void PrintFeed(Format format, Feed feed, Action<string> outputAction, XmlWriter writer, StringBuilder buffer, JavaScriptSerializer serializer)
 {
     switch (format)
     {
         case Format.Console:
             outputAction(ConsoleSplit);
             outputAction(string.Format("Feed: {0}" + Environment.NewLine, feed.Title));
             outputAction(ConsoleSplit);
             break;
         case Format.Xml:
             writer.WriteStartElement("feed");
             writer.WriteElementString("title", feed.Title);
             writer.WriteStartElement("items");
             break;
         case Format.Json:
             buffer.Append("{\"title\":");
             serializer.Serialize(feed.Title, buffer);
             buffer.Append(",\"items\":[");
             break;
     }
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public IEnumerable<FeedItem> GetItems(Feed feed, DateTimeOffset? since, bool ignoreCerts)
 {
     yield return new FeedItem("TestItem", DateTimeOffset.MinValue, new Uri("http://www.example.com"));
     yield return new FeedItem("TestItem2", DateTimeOffset.MinValue, new Uri("http://www.example.com/2"));
 }