XmlSchemaObjectTable.cs 3.7 KB

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