Code-X-Collection.cs 2.5 KB

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