Merge pull request #93 from konrad-kruczynski/dispatcher_timer_fix
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / XmlAnyElementAttributes.cs
1 //
2 // XmlAnyElementAttributes.cs: 
3 //
4 // Author:
5 //   John Donagher (john@webmeta.com)
6 //
7 // (C) 2002 John Donagher
8 //
9
10 //
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.
29 //
30
31 using System.Collections;
32 using System.Collections.Generic;
33
34 namespace System.Xml.Serialization
35 {
36         /// <summary>
37         /// Summary description for XmlAnyElementAttributes.
38         /// </summary>
39 #if MOONLIGHT
40         public class XmlAnyElementAttributes : IList {
41
42                 private List<XmlAnyElementAttribute> List = new List<XmlAnyElementAttribute> ();
43
44                 int IList.Add (object value)
45                 {
46                         return (List as IList).Add (value);
47                 }
48
49                 void IList.Clear ()
50                 {
51                         List.Clear ();
52                 }
53
54                 bool IList.Contains (object value)
55                 {
56                         return (List as IList).Contains (value);
57                 }
58
59                 int IList.IndexOf (object value)
60                 {
61                         return (List as IList).IndexOf (value);
62                 }
63
64                 void IList.Insert (int index, object value)
65                 {
66                         (List as IList).Insert (index, value);
67                 }
68
69                 bool IList.IsFixedSize {
70                         get { return (List as IList).IsFixedSize; }
71                 }
72
73                 bool IList.IsReadOnly {
74                         get { return (List as IList).IsReadOnly; }
75                 }
76
77                 void IList.Remove (object value)
78                 {
79                         (List as IList).Remove (value);
80                 }
81
82                 void IList.RemoveAt (int index)
83                 {
84                         List.RemoveAt (index);
85                 }
86
87                 object IList.this [int index] {
88                         get { return (List as IList) [index]; }
89                         set { (List as IList) [index] = value; }
90                 }
91
92                 void ICollection.CopyTo (Array array, int index)
93                 {
94                         (List as ICollection).CopyTo (array, index);
95                 }
96
97                 public int Count {
98                         get { return List.Count; }
99                 }
100
101                 bool ICollection.IsSynchronized {
102                         get { return (List as ICollection).IsSynchronized; }
103                 }
104
105                 object ICollection.SyncRoot {
106                         get { return (List as ICollection).SyncRoot; }
107                 }
108
109                 IEnumerator IEnumerable.GetEnumerator ()
110                 {
111                         return (List as IEnumerable).GetEnumerator ();
112                 }
113 #else
114         public class XmlAnyElementAttributes : CollectionBase {
115 #endif
116                 
117                 public XmlAnyElementAttribute this[int index] 
118                 {
119                         get 
120                         {
121                                 return (XmlAnyElementAttribute)List[index];
122                         }
123                         set 
124                         {
125                                 List[index] = value;
126                         }       
127                 }
128
129                 public int Add(XmlAnyElementAttribute attribute)
130                 {
131                         return (List as IList).Add (attribute);
132                 }
133
134                 public bool Contains(XmlAnyElementAttribute attribute)
135                 {
136                         return List.Contains(attribute);        
137                 }
138
139                 public int IndexOf(XmlAnyElementAttribute attribute)
140                 {
141                         return List.IndexOf(attribute);
142                 }
143
144                 public void Insert(int index, XmlAnyElementAttribute attribute)
145                 {
146                         List.Insert(index, attribute);
147                 }
148
149                 public void Remove(XmlAnyElementAttribute attribute)
150                 {
151                         List.Remove(attribute);
152                 }
153
154                 public void CopyTo(XmlAnyElementAttribute[] array,int index)
155                 {
156                         List.CopyTo(array, index);
157                 }
158                 
159                 internal void AddKeyHash (System.Text.StringBuilder sb)
160                 {
161                         if (Count == 0) return;
162                         
163                         sb.Append ("XAEAS ");
164                         for (int n=0; n<Count; n++)
165                                 this[n].AddKeyHash (sb);
166                         sb.Append ('|');
167                 }
168
169                 internal int Order {
170                         get {
171                                 foreach (XmlAnyElementAttribute e in this)
172                                         if (e.Order >= 0)
173                                                 return e.Order;
174                                 return -1;
175                         }
176                 }
177         }
178 }