updating to the latest module.
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaObjectTable.cs
1 // Author: Dwivedi, Ajay kumar\r
2 //            Adwiv@Yahoo.com\r
3
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
12 // 
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
15 // 
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 using System;\r
25 using System.Collections;\r
26 using System.Collections.Specialized;\r
27 using System.Xml;\r
28 \r
29 namespace System.Xml.Schema\r
30 {\r
31         /// <summary>\r
32         /// Summary description for XmlSchemaObjectTable.\r
33         /// </summary>\r
34         public class XmlSchemaObjectTable\r
35         {\r
36 //              private Hashtable table;\r
37                 private HybridDictionary table;\r
38 \r
39                 internal XmlSchemaObjectTable ()\r
40                 {\r
41 //                      table = new Hashtable(); \r
42                         table = new HybridDictionary (); \r
43                 }\r
44                 public int Count \r
45                 {\r
46                         get{ return table.Count; }\r
47                 }\r
48                 public XmlSchemaObject this [XmlQualifiedName name] \r
49                 {\r
50                         get{ return (XmlSchemaObject) table [name]; }\r
51                 }\r
52                 public ICollection Names \r
53                 {\r
54                         get{ return table.Keys; }\r
55                 }\r
56                 public ICollection Values \r
57                 {\r
58                         get{ return table.Values; }\r
59                 }\r
60 \r
61                 public bool Contains (XmlQualifiedName name)\r
62                 {\r
63                         return table.Contains (name);\r
64                 }\r
65                 public IDictionaryEnumerator GetEnumerator ()\r
66                 {\r
67                         return new XmlSchemaObjectTableEnumerator (this);\r
68                 }\r
69 \r
70                 internal void Add (XmlQualifiedName name, XmlSchemaObject value)\r
71                 {\r
72                         table [name] = value;\r
73                 }\r
74 \r
75                 internal void Clear ()\r
76                 {\r
77                         table.Clear ();\r
78                 }\r
79 \r
80                 internal void Set (XmlQualifiedName name, XmlSchemaObject value)\r
81                 {\r
82                         table [name] = value;\r
83                 }\r
84 \r
85                 internal class XmlSchemaObjectTableEnumerator : IDictionaryEnumerator\r
86                 {\r
87                         private IDictionaryEnumerator xenum;\r
88                         IEnumerable tmp;\r
89                         internal XmlSchemaObjectTableEnumerator (XmlSchemaObjectTable table)\r
90                         {\r
91                                 tmp = (IEnumerable) table.table;\r
92                                 xenum = (IDictionaryEnumerator) tmp.GetEnumerator ();\r
93                         }\r
94                         // Properties\r
95                         public XmlSchemaObject Current { \r
96                                 get {\r
97                                         return (XmlSchemaObject) xenum.Value; \r
98                                 }\r
99                         }\r
100                         public DictionaryEntry Entry {\r
101                                 get { return xenum.Entry; }\r
102                         }\r
103                         public XmlQualifiedName Key {\r
104                                 get { return (XmlQualifiedName) xenum.Key; }\r
105                         }\r
106                         public XmlSchemaObject Value {\r
107                                 get { return (XmlSchemaObject) xenum.Value; }\r
108                         }\r
109                         // Methods\r
110                         public bool MoveNext()\r
111                         {\r
112                                 return xenum.MoveNext();\r
113                         }\r
114 \r
115                         //Explicit Interface implementation\r
116                         bool IEnumerator.MoveNext()\r
117                         {\r
118                                 return xenum.MoveNext();\r
119                         }\r
120                         void IEnumerator.Reset()\r
121                         {\r
122                                 xenum.Reset();\r
123                         }\r
124                         object IEnumerator.Current\r
125                         {\r
126                                 get { return xenum.Entry; }\r
127                         }\r
128                         DictionaryEntry IDictionaryEnumerator.Entry {\r
129                                 get { return xenum.Entry; }\r
130                         }\r
131                         object IDictionaryEnumerator.Key {\r
132                                 get { return (XmlQualifiedName) xenum.Key; }\r
133                         }\r
134                         object IDictionaryEnumerator.Value {\r
135                                 get { return (XmlSchemaObject) xenum.Value; }\r
136                         }\r
137                 }\r
138         }\r
139 }\r