ExtendedPropertyCollection.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // System.Data.ObjectSpaces.Schema.ExtendedPropertyCollection.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.Collections;
  31. using System.Xml;
  32. namespace System.Data.ObjectSpaces.Schema {
  33. public class ExtendedPropertyCollection : CollectionBase
  34. {
  35. #region Fields
  36. ArrayList qnames;
  37. #endregion
  38. #region Constructors
  39. public ExtendedPropertyCollection ()
  40. {
  41. qnames = new ArrayList();
  42. }
  43. public ExtendedPropertyCollection (ExtendedProperty[] value)
  44. : this ()
  45. {
  46. AddRange (value);
  47. }
  48. public ExtendedPropertyCollection (ExtendedPropertyCollection value)
  49. : this ()
  50. {
  51. AddRange (value);
  52. }
  53. #endregion // Constructors
  54. #region Properties
  55. public ExtendedProperty this [int obj] {
  56. get { return (ExtendedProperty) List [obj]; }
  57. set {
  58. List [obj] = value;
  59. qnames [obj] = value.QualifiedName;
  60. }
  61. }
  62. [MonoTODO]
  63. public ExtendedProperty this [XmlQualifiedName type] {
  64. get { return (ExtendedProperty) List [qnames.IndexOf (type)]; }
  65. set { List [qnames.IndexOf (type)] = value; }
  66. }
  67. #endregion // Properties
  68. #region Methods
  69. public void Add (ExtendedProperty value)
  70. {
  71. Insert (Count, value);
  72. }
  73. public void AddRange (ExtendedProperty[] value)
  74. {
  75. foreach (ExtendedProperty p in value)
  76. Add (p);
  77. }
  78. public void AddRange (ExtendedPropertyCollection value)
  79. {
  80. foreach (ExtendedProperty p in value)
  81. Add (p);
  82. }
  83. public bool Contains (ExtendedProperty value)
  84. {
  85. return List.Contains (value);
  86. }
  87. public void CopyTo (ExtendedProperty[] array, int index)
  88. {
  89. List.CopyTo (array, index);
  90. }
  91. public int IndexOf (ExtendedProperty value)
  92. {
  93. return List.IndexOf (value);
  94. }
  95. [MonoTODO]
  96. public void Insert (int index, ExtendedProperty value)
  97. {
  98. List.Insert (index, value);
  99. qnames [index] = value.QualifiedName;
  100. }
  101. [MonoTODO]
  102. protected override void OnInsert (int index, object value)
  103. {
  104. }
  105. [MonoTODO]
  106. protected override void OnRemove (int index, object value)
  107. {
  108. }
  109. [MonoTODO]
  110. public void Remove (ExtendedProperty value)
  111. {
  112. int index = IndexOf (value);
  113. List.Remove (value);
  114. qnames.RemoveAt (index);
  115. }
  116. #endregion // Methods
  117. }
  118. }
  119. #endif // NET_2_0