Fix bug #703910 - implement Order support in XmlSerializer.
[mono-project.git] / mcs / class / System.XML / System.Xml.Serialization / XmlElementAttributes.cs
blobe66b62bbd32f1fd54096214dd5ae081d76f6c263
1 //
2 // XmlElementAttributes.cs:
3 //
4 // Author:
5 // John Donagher (john@webmeta.com)
6 //
7 // (C) 2002 John Donagher
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Collections.Generic;
34 namespace System.Xml.Serialization
36 /// <summary>
37 /// Summary description for XmlElementAttributes.
38 /// </summary>
39 #if MOONLIGHT
40 public class XmlElementAttributes : IList {
42 private List<XmlElementAttribute> List = new List<XmlElementAttribute> ();
44 int IList.Add (object value)
46 return (List as IList).Add (value);
49 void IList.Clear ()
51 List.Clear ();
54 bool IList.Contains (object value)
56 return (List as IList).Contains (value);
59 int IList.IndexOf (object value)
61 return (List as IList).IndexOf (value);
64 void IList.Insert (int index, object value)
66 (List as IList).Insert (index, value);
69 bool IList.IsFixedSize {
70 get { return (List as IList).IsFixedSize; }
73 bool IList.IsReadOnly {
74 get { return (List as IList).IsReadOnly; }
77 void IList.Remove (object value)
79 (List as IList).Remove (value);
82 void IList.RemoveAt (int index)
84 List.RemoveAt (index);
87 object IList.this [int index] {
88 get { return (List as IList) [index]; }
89 set { (List as IList) [index] = value; }
92 void ICollection.CopyTo (Array array, int index)
94 (List as ICollection).CopyTo (array, index);
97 public int Count {
98 get { return List.Count; }
101 bool ICollection.IsSynchronized {
102 get { return (List as ICollection).IsSynchronized; }
105 object ICollection.SyncRoot {
106 get { return (List as ICollection).SyncRoot; }
109 IEnumerator IEnumerable.GetEnumerator ()
111 return (List as IEnumerable).GetEnumerator ();
113 #else
114 public class XmlElementAttributes : CollectionBase {
115 #endif
116 public XmlElementAttribute this [int index] {
117 get {
118 return (XmlElementAttribute)List [index];
120 set {
121 List [index] = value;
125 public int Add (XmlElementAttribute attribute)
127 return (List as IList).Add (attribute);
130 public bool Contains(XmlElementAttribute attribute)
132 return List.Contains(attribute);
135 public int IndexOf(XmlElementAttribute attribute)
137 return List.IndexOf(attribute);
140 public void Insert(int index, XmlElementAttribute attribute)
142 List.Insert(index, attribute);
145 public void Remove(XmlElementAttribute attribute)
147 List.Remove(attribute);
150 public void CopyTo(XmlElementAttribute[] array,int index)
152 List.CopyTo(array, index);
155 internal void AddKeyHash (System.Text.StringBuilder sb)
157 if (Count == 0) return;
159 sb.Append ("XEAS ");
160 for (int n=0; n<Count; n++)
161 this[n].AddKeyHash (sb);
162 sb.Append ('|');
165 internal int Order {
166 get {
167 foreach (XmlElementAttribute e in this)
168 if (e.Order >= 0)
169 return e.Order;
170 return -1;