XmlSchemaObjectTable.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Collections;
  5. using System.Xml;
  6. namespace System.Xml.Schema
  7. {
  8. /// <summary>
  9. /// Summary description for XmlSchemaObjectTable.
  10. /// </summary>
  11. public class XmlSchemaObjectTable
  12. {
  13. private Hashtable table;
  14. internal XmlSchemaObjectTable()
  15. {
  16. table = new Hashtable();
  17. }
  18. public int Count
  19. {
  20. get{ return table.Count; }
  21. }
  22. public XmlSchemaObject this [XmlQualifiedName name]
  23. {
  24. get{ return (XmlSchemaObject) table [name]; }
  25. }
  26. public ICollection Names
  27. {
  28. get{ return table.Keys; }
  29. }
  30. public ICollection Values
  31. {
  32. get{ return table.Values; }
  33. }
  34. public bool Contains(XmlQualifiedName name)
  35. {
  36. return table.Contains(name);
  37. }
  38. public IDictionaryEnumerator GetEnumerator()
  39. {
  40. return new XmlSchemaObjectTableEnumerator (this);
  41. }
  42. internal void Add(XmlQualifiedName name, XmlSchemaObject value)
  43. {
  44. if (table.ContainsKey (name))
  45. throw new XmlSchemaException (
  46. "Schema object for the name " + name + " already exists in this table.", value, null);
  47. table [name] = value;
  48. }
  49. internal void Clear ()
  50. {
  51. table.Clear ();
  52. }
  53. internal void Set(XmlQualifiedName name, XmlSchemaObject value)
  54. {
  55. table [name] = value;
  56. }
  57. internal class XmlSchemaObjectTableEnumerator : IDictionaryEnumerator
  58. {
  59. private IDictionaryEnumerator xenum;
  60. IEnumerable tmp;
  61. XmlSchemaObjectTable table;
  62. internal XmlSchemaObjectTableEnumerator (XmlSchemaObjectTable table)
  63. {
  64. this.table = table;
  65. tmp = (IEnumerable) table.table;
  66. xenum = (IDictionaryEnumerator) tmp.GetEnumerator ();
  67. }
  68. // Properties
  69. public XmlSchemaObject Current {
  70. get {
  71. return (XmlSchemaObject) xenum.Value;
  72. }
  73. }
  74. public DictionaryEntry Entry {
  75. get { return xenum.Entry; }
  76. }
  77. public XmlQualifiedName Key {
  78. get { return (XmlQualifiedName) xenum.Key; }
  79. }
  80. public XmlSchemaObject Value {
  81. get { return (XmlSchemaObject) xenum.Value; }
  82. }
  83. // Methods
  84. public bool MoveNext()
  85. {
  86. return xenum.MoveNext();
  87. }
  88. //Explicit Interface implementation
  89. bool IEnumerator.MoveNext()
  90. {
  91. return xenum.MoveNext();
  92. }
  93. void IEnumerator.Reset()
  94. {
  95. xenum.Reset();
  96. }
  97. object IEnumerator.Current
  98. {
  99. get { return xenum.Entry; }
  100. }
  101. DictionaryEntry IDictionaryEnumerator.Entry {
  102. get { return xenum.Entry; }
  103. }
  104. object IDictionaryEnumerator.Key {
  105. get { return (XmlQualifiedName) xenum.Key; }
  106. }
  107. object IDictionaryEnumerator.Value {
  108. get { return (XmlSchemaObject) xenum.Value; }
  109. }
  110. }
  111. }
  112. }