SyndicationElementExtensionCollection.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // SyndicationElementExtensionCollection.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Collections.ObjectModel;
  31. using System.IO;
  32. using System.Runtime.Serialization;
  33. using System.Text;
  34. using System.Xml;
  35. using System.Xml.Serialization;
  36. namespace System.ServiceModel.Syndication
  37. {
  38. public sealed class SyndicationElementExtensionCollection : Collection<SyndicationElementExtension>
  39. {
  40. internal SyndicationElementExtensionCollection ()
  41. {
  42. }
  43. internal SyndicationElementExtensionCollection (IEnumerable<SyndicationElementExtension> source)
  44. {
  45. if (source == null)
  46. throw new ArgumentNullException ("source");
  47. foreach (SyndicationElementExtension item in source)
  48. Add (item);
  49. }
  50. public void Add (object extension)
  51. {
  52. Add (new SyndicationElementExtension (extension));
  53. }
  54. public void Add (object dataContractExtension, DataContractSerializer serializer)
  55. {
  56. Add (new SyndicationElementExtension (dataContractExtension, serializer));
  57. }
  58. public void Add (object xmlSerializerExtension, XmlSerializer serializer)
  59. {
  60. Add (new SyndicationElementExtension (xmlSerializerExtension, serializer));
  61. }
  62. public void Add (string outerName, string outerNamespace, object dataContractExtension)
  63. {
  64. Add (new SyndicationElementExtension (outerName, outerNamespace, dataContractExtension));
  65. }
  66. public void Add (string outerName, string outerNamespace, object dataContractExtension, XmlObjectSerializer dataContractSerializer)
  67. {
  68. Add (new SyndicationElementExtension (outerName, outerNamespace, dataContractExtension, dataContractSerializer));
  69. }
  70. public void Add (XmlReader xmlReader)
  71. {
  72. Add (new SyndicationElementExtension (xmlReader));
  73. }
  74. internal new void Add (SyndicationElementExtension item)
  75. {
  76. base.Add (item);
  77. }
  78. [MonoTODO ("Find out what is expected here")]
  79. protected override void ClearItems ()
  80. {
  81. base.ClearItems ();
  82. }
  83. [MonoTODO]
  84. public XmlReader GetReaderAtElementExtensions ()
  85. {
  86. throw new NotImplementedException ();
  87. }
  88. protected override void InsertItem (int index, SyndicationElementExtension item)
  89. {
  90. if (item == null)
  91. throw new ArgumentNullException ("item");
  92. base.InsertItem (index, item);
  93. }
  94. public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace)
  95. {
  96. Collection<TExtension> c = new Collection<TExtension> ();
  97. foreach (SyndicationElementExtension e in this)
  98. if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
  99. c.Add (e.GetObject<TExtension> ());
  100. return c;
  101. }
  102. public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace, XmlObjectSerializer serializer)
  103. {
  104. if (serializer == null)
  105. throw new ArgumentNullException ("serializer");
  106. Collection<TExtension> c = new Collection<TExtension> ();
  107. foreach (SyndicationElementExtension e in this)
  108. if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
  109. c.Add (e.GetObject<TExtension> (serializer));
  110. return c;
  111. }
  112. public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace, XmlSerializer serializer)
  113. {
  114. if (serializer == null)
  115. throw new ArgumentNullException ("serializer");
  116. Collection<TExtension> c = new Collection<TExtension> ();
  117. foreach (SyndicationElementExtension e in this)
  118. if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
  119. c.Add (e.GetObject<TExtension> (serializer));
  120. return c;
  121. }
  122. [MonoTODO ("Find out what is expected here")]
  123. protected override void RemoveItem (int index)
  124. {
  125. base.RemoveItem (index);
  126. }
  127. protected override void SetItem (int index, SyndicationElementExtension item)
  128. {
  129. if (item == null)
  130. throw new ArgumentNullException ("item");
  131. base.SetItem (index, item);
  132. }
  133. }
  134. }