FieldNameLookup.cs 3.0 KB

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