StringCollection.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // StringCollection.cs
  3. //
  4. // Authors:
  5. // John Barnette ([email protected])
  6. // Sean MacIsaac ([email protected])
  7. // Ben Maurer ([email protected])
  8. //
  9. // (C) 2003 Ben Maurer
  10. // Copyright (C) 2001 John Barnette
  11. // (C) Ximian, Inc. http://www.ximian.com
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. namespace System.Collections.Specialized {
  33. [Serializable]
  34. public class StringCollection : IList {
  35. ArrayList data = new ArrayList ();
  36. public string this [int index] {
  37. get { return (string)data [index]; }
  38. set { data [index] = value; }
  39. }
  40. public int Count {
  41. get { return data.Count; }
  42. }
  43. bool IList.IsReadOnly {
  44. get { return false; }
  45. }
  46. bool IList.IsFixedSize {
  47. get { return false; }
  48. }
  49. public int Add (string value) {
  50. return data.Add (value);
  51. }
  52. public void AddRange (string [] value) {
  53. if (value == null)
  54. throw new ArgumentNullException ("value");
  55. data.AddRange (value);
  56. }
  57. public void Clear () {
  58. data.Clear ();
  59. }
  60. public bool Contains (string value) {
  61. return data.Contains (value);
  62. }
  63. public void CopyTo (string [] array, int index) {
  64. data.CopyTo (array, index);
  65. }
  66. public StringEnumerator GetEnumerator () {
  67. return new StringEnumerator (this);
  68. }
  69. public int IndexOf (string value) {
  70. return data.IndexOf (value);
  71. }
  72. public void Insert(int index, string value) {
  73. data.Insert (index, value);
  74. }
  75. public bool IsReadOnly {
  76. get { return false; }
  77. }
  78. public bool IsSynchronized {
  79. get { return false; }
  80. }
  81. public void Remove (string value) {
  82. data.Remove (value);
  83. }
  84. public void RemoveAt (int index) {
  85. data.RemoveAt (index);
  86. }
  87. public object SyncRoot {
  88. get { return this; }
  89. }
  90. object IList.this [int index] {
  91. get { return this [index]; }
  92. set { this [index] = (string)value; }
  93. }
  94. int IList.Add (object value) {
  95. return Add ((string)value);
  96. }
  97. bool IList.Contains (object value) {
  98. return Contains ((string) value);
  99. }
  100. int IList.IndexOf (object value) {
  101. return IndexOf ((string)value);
  102. }
  103. void IList.Insert (int index, object value) {
  104. Insert (index, (string)value);
  105. }
  106. void IList.Remove (object value) {
  107. Remove ((string)value);
  108. }
  109. void ICollection.CopyTo (Array array, int index) {
  110. data.CopyTo (array, index);
  111. }
  112. IEnumerator IEnumerable.GetEnumerator () {
  113. return data.GetEnumerator ();
  114. }
  115. }
  116. }