CodeClassMemberCollection.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // System.CodeDom CodeClassMemberCollection Class implementation
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // (C) 2001 Ximian, Inc.
  8. //
  9. namespace System.CodeDom {
  10. using System.Collections;
  11. public class CodeClassMemberCollection : IList, ICollection, IEnumerable {
  12. ArrayList classMembers;
  13. //
  14. // Constructors
  15. //
  16. public CodeClassMemberCollection ()
  17. {
  18. classMembers = new ArrayList ();
  19. }
  20. //
  21. // Properties
  22. //
  23. public int Count {
  24. get {
  25. return classMembers.Count;
  26. }
  27. }
  28. public bool IsFixedSize {
  29. get {
  30. return true;
  31. }
  32. }
  33. //
  34. // Methods
  35. //
  36. public void Add (CodeClassMember value)
  37. {
  38. classMembers.Add (value);
  39. }
  40. public void AddRange (CodeClassMember [] values)
  41. {
  42. foreach (CodeClassMember ca in values)
  43. classMembers.Add (ca);
  44. }
  45. public void Clear ()
  46. {
  47. classMembers.Clear ();
  48. }
  49. private class Enumerator : IEnumerator {
  50. private CodeClassMemberCollection collection;
  51. private int currentIndex = -1;
  52. internal Enumerator (CodeClassMemberCollection collection)
  53. {
  54. this.collection = collection;
  55. }
  56. public object Current {
  57. get {
  58. if (currentIndex == collection.Count)
  59. throw new InvalidOperationException ();
  60. return collection [currentIndex];
  61. }
  62. }
  63. public bool MoveNext ()
  64. {
  65. if (currentIndex > collection.Count)
  66. throw new InvalidOperationException ();
  67. return ++currentIndex < collection.Count;
  68. }
  69. public void Reset ()
  70. {
  71. currentIndex = -1;
  72. }
  73. }
  74. public IEnumerator GetEnumerator ()
  75. {
  76. return new CodeClassMemberCollection.Enumerator (this);
  77. }
  78. //
  79. // IList method implementations
  80. //
  81. public int Add (object value)
  82. {
  83. return classMembers.Add (value);
  84. }
  85. public bool Contains (Object value)
  86. {
  87. return classMembers.Contains (value);
  88. }
  89. public int IndexOf (Object value)
  90. {
  91. return classMembers.IndexOf (value);
  92. }
  93. public void Insert (int index, Object value)
  94. {
  95. classMembers [index] = value;
  96. }
  97. public object this[int index] {
  98. get {
  99. return classMembers [index];
  100. }
  101. set {
  102. classMembers [index] = value;
  103. }
  104. }
  105. public void Remove (object value)
  106. {
  107. classMembers.Remove (value);
  108. }
  109. public void RemoveAt (int index)
  110. {
  111. classMembers.RemoveAt (index);
  112. }
  113. //
  114. // ICollection method implementations
  115. //
  116. public void CopyTo (Array array, int index)
  117. {
  118. classMembers.CopyTo (array, index);
  119. }
  120. public object SyncRoot {
  121. get {
  122. return classMembers.SyncRoot;
  123. }
  124. }
  125. public bool IsReadOnly {
  126. get {
  127. return false;
  128. }
  129. }
  130. public bool IsSynchronized {
  131. get {
  132. return classMembers.IsSynchronized;
  133. }
  134. }
  135. }
  136. }