2 // SyndicationElementExtensionCollection.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
32 using System.Runtime.Serialization;
35 using System.Xml.Serialization;
37 namespace System.ServiceModel.Syndication
39 public sealed class SyndicationElementExtensionCollection : Collection<SyndicationElementExtension>
41 internal SyndicationElementExtensionCollection ()
45 internal SyndicationElementExtensionCollection (IEnumerable<SyndicationElementExtension> source)
48 throw new ArgumentNullException ("source");
49 foreach (SyndicationElementExtension item in source)
53 public void Add (object extension)
55 Add (new SyndicationElementExtension (extension));
58 public void Add (object dataContractExtension, DataContractSerializer serializer)
60 Add (new SyndicationElementExtension (dataContractExtension, serializer));
63 public void Add (object xmlSerializerExtension, XmlSerializer serializer)
65 Add (new SyndicationElementExtension (xmlSerializerExtension, serializer));
68 public void Add (string outerName, string outerNamespace, object dataContractExtension)
70 Add (new SyndicationElementExtension (outerName, outerNamespace, dataContractExtension));
73 public void Add (string outerName, string outerNamespace, object dataContractExtension, XmlObjectSerializer dataContractSerializer)
75 Add (new SyndicationElementExtension (outerName, outerNamespace, dataContractExtension, dataContractSerializer));
78 public void Add (XmlReader xmlReader)
80 Add (new SyndicationElementExtension (xmlReader));
83 new void Add (SyndicationElementExtension item)
88 [MonoTODO ("Find out what is expected here")]
89 protected override void ClearItems ()
95 public XmlReader GetReaderAtElementExtensions ()
97 throw new NotImplementedException ();
100 protected override void InsertItem (int index, SyndicationElementExtension item)
103 throw new ArgumentNullException ("item");
104 base.InsertItem (index, item);
107 public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace)
109 Collection<TExtension> c = new Collection<TExtension> ();
110 foreach (SyndicationElementExtension e in this)
111 if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
112 c.Add (e.GetObject<TExtension> ());
116 public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace, XmlObjectSerializer serializer)
118 if (serializer == null)
119 throw new ArgumentNullException ("serializer");
121 Collection<TExtension> c = new Collection<TExtension> ();
122 foreach (SyndicationElementExtension e in this)
123 if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
124 c.Add (e.GetObject<TExtension> (serializer));
128 public Collection<TExtension> ReadElementExtensions<TExtension> (string extensionName, string extensionNamespace, XmlSerializer serializer)
130 if (serializer == null)
131 throw new ArgumentNullException ("serializer");
133 Collection<TExtension> c = new Collection<TExtension> ();
134 foreach (SyndicationElementExtension e in this)
135 if (e.OuterName == extensionName && e.OuterNamespace == extensionNamespace)
136 c.Add (e.GetObject<TExtension> (serializer));
140 [MonoTODO ("Find out what is expected here")]
141 protected override void RemoveItem (int index)
143 base.RemoveItem (index);
146 protected override void SetItem (int index, SyndicationElementExtension item)
149 throw new ArgumentNullException ("item");
150 base.SetItem (index, item);