SyndicationSerializerUtil.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.IO;
  3. using System.Xml;
  4. using System.ServiceModel.Syndication;
  5. class SyndicationSerializerUtil
  6. {
  7. private static int feedIndx = 0;
  8. public static void DumpFeed(SyndicationFeed f, string label)
  9. {
  10. string path = Path.Combine("Test", label);
  11. f.LastUpdatedTime = FeedLib.FixedChangedDate;
  12. using (XmlTextWriter writer = new XmlTextWriter(path + ".atom.xml", null))
  13. {
  14. Console.WriteLine("Writing " + path + ".atom.xml");
  15. writer.Formatting = Formatting.Indented;
  16. Atom10Serializer serializer = new Atom10Serializer();
  17. serializer.WriteTo(writer, f);
  18. }
  19. using (XmlTextWriter writer = new XmlTextWriter(path + ".rss.xml", null))
  20. {
  21. Console.WriteLine("Writing " + path + ".rss.xml");
  22. writer.Formatting = Formatting.Indented;
  23. Rss20Serializer serializer = new Rss20Serializer();
  24. serializer.WriteTo(writer, f);
  25. }
  26. }
  27. static int Main (string[] args)
  28. {
  29. DumpFeed(FeedLib.EmptyFeed, "EmptyFeed");
  30. DumpFeed(FeedLib.FeedNoItems, "FeedNoItems");
  31. DumpFeed(FeedLib.FeedWithItems, "FeedWithItems");
  32. DumpFeed(FeedLib.FeedNoItemsSimpleProps, "FeedNoItemsSimpleProps");
  33. return 0;
  34. }
  35. }