XmlSchemaObjectTable.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.",
  47. 0, 0, value, null, null);
  48. table [name] = value;
  49. }
  50. internal void Clear ()
  51. {
  52. table.Clear ();
  53. }
  54. internal void Set(XmlQualifiedName name, XmlSchemaObject value)
  55. {
  56. table [name] = value;
  57. }
  58. internal class XmlSchemaObjectTableEnumerator : IDictionaryEnumerator
  59. {
  60. private IDictionaryEnumerator xenum;
  61. IEnumerable tmp;
  62. XmlSchemaObjectTable table;
  63. internal XmlSchemaObjectTableEnumerator (XmlSchemaObjectTable table)
  64. {
  65. this.table = table;
  66. tmp = (IEnumerable) table.table;
  67. xenum = (IDictionaryEnumerator) tmp.GetEnumerator ();
  68. }
  69. // Properties
  70. public XmlSchemaObject Current {
  71. get {
  72. return (XmlSchemaObject) xenum.Value;
  73. }
  74. }
  75. public DictionaryEntry Entry {
  76. get { return xenum.Entry; }
  77. }
  78. public XmlQualifiedName Key {
  79. get { return (XmlQualifiedName) xenum.Key; }
  80. }
  81. public XmlSchemaObject Value {
  82. get { return (XmlSchemaObject) xenum.Value; }
  83. }
  84. // Methods
  85. public bool MoveNext()
  86. {
  87. return xenum.MoveNext();
  88. }
  89. //Explicit Interface implementation
  90. bool IEnumerator.MoveNext()
  91. {
  92. return xenum.MoveNext();
  93. }
  94. void IEnumerator.Reset()
  95. {
  96. xenum.Reset();
  97. }
  98. object IEnumerator.Current
  99. {
  100. get { return xenum.Value; }
  101. }
  102. DictionaryEntry IDictionaryEnumerator.Entry {
  103. get { return xenum.Entry; }
  104. }
  105. object IDictionaryEnumerator.Key {
  106. get { return (XmlQualifiedName) xenum.Key; }
  107. }
  108. object IDictionaryEnumerator.Value {
  109. get { return (XmlSchemaObject) xenum.Value; }
  110. }
  111. }
  112. }
  113. }