CodeNamespaceImportCollection.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // System.CodeDom CodeNamespaceImportCollection Class implementation
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. // Daniel Stodden ([email protected])
  7. //
  8. // (C) 2001 Ximian, Inc.
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System.Runtime.InteropServices;
  31. using System.Collections;
  32. namespace System.CodeDom
  33. {
  34. /*
  35. * Should probably be derived from CollectionBase like any
  36. * other System.CodeDom.*Collection. MS docs say it currently
  37. * is not, for whichever reason.
  38. */
  39. [Serializable]
  40. [ClassInterface(ClassInterfaceType.AutoDispatch)]
  41. [ComVisible(true)]
  42. public class CodeNamespaceImportCollection
  43. : IList, ICollection, IEnumerable
  44. {
  45. private ArrayList namespaceImports;
  46. //
  47. // Constructors
  48. //
  49. public CodeNamespaceImportCollection ()
  50. {
  51. namespaceImports = new ArrayList();
  52. }
  53. //
  54. // Properties
  55. //
  56. public int Count {
  57. get {
  58. return namespaceImports.Count;
  59. }
  60. }
  61. public CodeNamespaceImport this [int index] {
  62. get {
  63. return (CodeNamespaceImport)namespaceImports[index];
  64. }
  65. set {
  66. namespaceImports[index] = value;
  67. }
  68. }
  69. //
  70. // Methods
  71. //
  72. public void Add (CodeNamespaceImport value)
  73. {
  74. namespaceImports.Add (value);
  75. }
  76. public void AddRange (CodeNamespaceImport [] value)
  77. {
  78. foreach (CodeNamespaceImport elem in value)
  79. namespaceImports.Add (elem);
  80. }
  81. public void Clear ()
  82. {
  83. namespaceImports.Clear ();
  84. }
  85. // IList implementation
  86. bool IList.IsFixedSize {
  87. get {
  88. return false;
  89. }
  90. }
  91. bool IList.IsReadOnly {
  92. get {
  93. return false;
  94. }
  95. }
  96. object IList.this[int index] {
  97. get {
  98. return namespaceImports[index];
  99. }
  100. set {
  101. namespaceImports[index] = value;
  102. }
  103. }
  104. int IList.Add( object value )
  105. {
  106. return namespaceImports.Add( value );
  107. }
  108. bool IList.Contains( object value )
  109. {
  110. return namespaceImports.Contains( value );
  111. }
  112. int IList.IndexOf( object value )
  113. {
  114. return namespaceImports.IndexOf( value );
  115. }
  116. void IList.Insert( int index, object value )
  117. {
  118. namespaceImports.Insert( index, value );
  119. }
  120. void IList.Remove( object value )
  121. {
  122. namespaceImports.Remove( value );
  123. }
  124. void IList.RemoveAt( int index )
  125. {
  126. namespaceImports.RemoveAt( index );
  127. }
  128. // ICollection implementation
  129. object ICollection.SyncRoot {
  130. get {
  131. return namespaceImports.SyncRoot;
  132. }
  133. }
  134. bool ICollection.IsSynchronized {
  135. get {
  136. return namespaceImports.IsSynchronized;
  137. }
  138. }
  139. void ICollection.CopyTo( Array array, int index )
  140. {
  141. namespaceImports.CopyTo( array, index );
  142. }
  143. // IEnumerable implementation
  144. public IEnumerator GetEnumerator ()
  145. {
  146. return namespaceImports.GetEnumerator();
  147. }
  148. }
  149. }