XmlSchemas.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // System.Xml.Serialization.XmlSchemas
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System.Collections;
  10. using System.Xml.Schema;
  11. namespace System.Xml.Serialization {
  12. public class XmlSchemas : CollectionBase {
  13. #region Fields
  14. static Hashtable table = new Hashtable ();
  15. #endregion
  16. #region Constructors
  17. public XmlSchemas ()
  18. {
  19. }
  20. #endregion // Constructors
  21. #region Properties
  22. public XmlSchema this [int index] {
  23. get {
  24. if (index < 0 || index > Count)
  25. throw new ArgumentOutOfRangeException ();
  26. return (XmlSchema) List [index];
  27. }
  28. set { List [index] = value; }
  29. }
  30. public XmlSchema this [string ns] {
  31. get { return (XmlSchema) table[ns]; }
  32. }
  33. #endregion // Properties
  34. #region Methods
  35. public int Add (XmlSchema schema)
  36. {
  37. Insert (Count, schema);
  38. return (Count - 1);
  39. }
  40. public void Add (XmlSchemas schemas)
  41. {
  42. foreach (XmlSchema schema in schemas)
  43. Add (schema);
  44. }
  45. public bool Contains (XmlSchema schema)
  46. {
  47. return List.Contains (schema);
  48. }
  49. public void CopyTo (XmlSchema[] array, int index)
  50. {
  51. List.CopyTo (array, index);
  52. }
  53. public int IndexOf (XmlSchema schema)
  54. {
  55. return List.IndexOf (schema);
  56. }
  57. public void Insert (int index, XmlSchema schema)
  58. {
  59. List.Insert (index, schema);
  60. }
  61. [MonoTODO]
  62. public static bool IsDataSet (XmlSchema schema)
  63. {
  64. throw new NotImplementedException ();
  65. }
  66. protected override void OnClear ()
  67. {
  68. table.Clear ();
  69. }
  70. protected override void OnInsert (int index, object value)
  71. {
  72. table [((XmlSchema) value).TargetNamespace] = value;
  73. }
  74. protected override void OnRemove (int index, object value)
  75. {
  76. table.Remove (value);
  77. }
  78. protected override void OnSet (int index, object oldValue, object newValue)
  79. {
  80. table [((XmlSchema) oldValue).TargetNamespace] = newValue;
  81. }
  82. public void Remove (XmlSchema schema)
  83. {
  84. List.Remove (schema);
  85. }
  86. #endregion // Methods
  87. }
  88. }