CodeCatchClauseCollection.cs 2.7 KB

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