SyndicationFeed.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // System.ServiceModel.Syndication.SyndicationFeed
  3. //
  4. // Authors:
  5. // Joel Reed ([email protected])
  6. //
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.Xml;
  29. using System.Collections.ObjectModel;
  30. namespace System.ServiceModel.Syndication
  31. {
  32. public class SyndicationFeed
  33. {
  34. private string id;
  35. private TextSyndicationContent description;
  36. private TextSyndicationContent title;
  37. private Collection<SyndicationItem> items;
  38. private DateTime lastUpdatedTime;
  39. private TextSyndicationContent copyright;
  40. private string generator;
  41. private string language;
  42. private Uri imageUrl;
  43. private Collection<SyndicationLink> links;
  44. private Collection <SyndicationCategory> categories;
  45. private Collection <SyndicationPerson> contributors;
  46. public SyndicationFeed()
  47. {
  48. items = new Collection<SyndicationItem>();
  49. links = new Collection<SyndicationLink>();
  50. lastUpdatedTime = DateTime.Now.ToUniversalTime();
  51. }
  52. public SyndicationFeed(string title, string description,
  53. Uri feedAlternateLink) : this()
  54. {
  55. this.title = new TextSyndicationContent(title);
  56. this.description = new TextSyndicationContent(description);
  57. links.Add(SyndicationLink.CreateAlternateLink(feedAlternateLink));
  58. }
  59. public void WriteTo(XmlWriter writer, SyndicationSerializer serializer)
  60. {
  61. serializer.WriteTo(writer, this);
  62. }
  63. public string Id
  64. {
  65. get { return id; }
  66. set { id = value; }
  67. }
  68. public TextSyndicationContent Copyright
  69. {
  70. get { return copyright; }
  71. set { copyright = value; }
  72. }
  73. public string Generator
  74. {
  75. get { return generator; }
  76. set { generator = value; }
  77. }
  78. public string Language
  79. {
  80. get { return language; }
  81. set { language = value; }
  82. }
  83. public DateTime LastUpdatedTime
  84. {
  85. get { return lastUpdatedTime; }
  86. set { lastUpdatedTime = value; }
  87. }
  88. public Uri ImageUrl
  89. {
  90. get { return imageUrl; }
  91. set { imageUrl = value; }
  92. }
  93. public Collection<SyndicationItem> Items {
  94. get { return items; }
  95. }
  96. public Collection<SyndicationLink> Links {
  97. get { return links; }
  98. }
  99. public TextSyndicationContent Description {
  100. get { return description; }
  101. set { description = value; }
  102. }
  103. public TextSyndicationContent Title {
  104. get { return title; }
  105. set { title = value; }
  106. }
  107. public Collection <SyndicationPerson> Contributors {
  108. get { return contributors; }
  109. }
  110. public Collection <SyndicationCategory> Categories {
  111. get { return categories; }
  112. }
  113. }
  114. }