CodeDirectiveCollection.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // System.CodeDom CodeDirectiveCollection class
  3. //
  4. // Authors:
  5. // Marek Safar ([email protected])
  6. // Sebastien Pouliot <[email protected]>
  7. //
  8. // (C) 2004 Ximian, Inc.
  9. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  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. #if NET_2_0
  31. using System.Runtime.InteropServices;
  32. namespace System.CodeDom
  33. {
  34. [Serializable]
  35. [ComVisible (true), ClassInterface (ClassInterfaceType.AutoDispatch)]
  36. public class CodeDirectiveCollection: System.Collections.CollectionBase {
  37. public CodeDirectiveCollection ()
  38. {
  39. }
  40. public CodeDirectiveCollection (CodeDirective[] value)
  41. {
  42. AddRange (value);
  43. }
  44. public CodeDirectiveCollection (CodeDirectiveCollection value)
  45. {
  46. AddRange (value);
  47. }
  48. public CodeDirective this [int index] {
  49. get { return (CodeDirective) List [index]; }
  50. set { List [index] = value; }
  51. }
  52. public int Add (CodeDirective value)
  53. {
  54. return List.Add (value);
  55. }
  56. public void AddRange (CodeDirective[] value )
  57. {
  58. foreach (CodeDirective cd in value)
  59. Add (cd);
  60. }
  61. public void AddRange (CodeDirectiveCollection value)
  62. {
  63. foreach (CodeDirective cd in value)
  64. Add (cd);
  65. }
  66. public bool Contains (CodeDirective value)
  67. {
  68. return List.Contains (value);
  69. }
  70. public void CopyTo (CodeDirective[] array, int index)
  71. {
  72. List.CopyTo (array, index);
  73. }
  74. public int IndexOf (CodeDirective value)
  75. {
  76. return List.IndexOf (value);
  77. }
  78. public void Insert (int index, CodeDirective value)
  79. {
  80. List.Insert (index, value);
  81. }
  82. public void Remove (CodeDirective value)
  83. {
  84. int index = IndexOf (value);
  85. if (index < 0) {
  86. string msg = Locale.GetText ("The specified object is not found in the collection");
  87. throw new ArgumentException (msg, "value");
  88. }
  89. RemoveAt (index);
  90. }
  91. }
  92. }
  93. #endif