FieldNameLookup.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // System.Data.Common.FieldNameLookup.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System.Collections;
  10. using System.Data;
  11. namespace System.Data.Common {
  12. #if NET_1_2
  13. // FIXME: Need to clean this up
  14. public sealed class FieldNameLookup
  15. #else
  16. internal sealed class FieldNameLookup : ICollection, IEnumerable
  17. #endif
  18. {
  19. #region Fields
  20. ArrayList list;
  21. #endregion
  22. #region Constructors
  23. public FieldNameLookup ()
  24. {
  25. list = new ArrayList ();
  26. }
  27. public FieldNameLookup (DataTable schemaTable)
  28. : this ()
  29. {
  30. foreach (DataRow row in schemaTable.Rows)
  31. list.Add ((string) row["ColumnName"]);
  32. }
  33. #endregion
  34. #region Properties
  35. public int Count {
  36. get { return list.Count; }
  37. }
  38. public bool IsFixedSize {
  39. get { return false; }
  40. }
  41. public bool IsReadOnly {
  42. get { return false; }
  43. }
  44. public bool IsSynchronized {
  45. get { return list.IsSynchronized; }
  46. }
  47. public string this [int index] {
  48. get { return (string) list[index]; }
  49. set { list[index] = value; }
  50. }
  51. public object SyncRoot {
  52. get { return list.SyncRoot; }
  53. }
  54. #endregion
  55. #region Methods
  56. public int Add (object value)
  57. {
  58. return list.Add (value);
  59. }
  60. public void Clear ()
  61. {
  62. list.Clear ();
  63. }
  64. public bool Contains (object value)
  65. {
  66. return list.Contains (value);
  67. }
  68. public void CopyTo (Array array, int index)
  69. {
  70. list.CopyTo (array, index);
  71. }
  72. #if ONLY_1_0 || ONLY_1_1
  73. IEnumerator IEnumerable.GetEnumerator ()
  74. {
  75. return list.GetEnumerator ();
  76. }
  77. #endif
  78. public int IndexOf (object value)
  79. {
  80. return list.IndexOf (value);
  81. }
  82. public void Insert (int index, object value)
  83. {
  84. list.Insert (index, value);
  85. }
  86. public void Remove (object value)
  87. {
  88. list.Remove (value);
  89. }
  90. public void RemoveAt (int index)
  91. {
  92. list.RemoveAt (index);
  93. }
  94. #endregion // Methods
  95. }
  96. }