PageRenderTime 34ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/System.Data/System.Data.Common/FieldNameLookup.cs

https://bitbucket.org/danipen/mono
C# | 139 lines | 81 code | 28 blank | 30 comment | 0 complexity | de947b3dfbade54adcaa2b5ca67eaa41 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. //
  2. // System.Data.Common.FieldNameLookup.cs
  3. //
  4. // Author:
  5. // Tim Coleman (tim@timcoleman.com)
  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. internal sealed class FieldNameLookup : ICollection, IEnumerable
  35. {
  36. #region Fields
  37. ArrayList list;
  38. #endregion
  39. #region Constructors
  40. public FieldNameLookup ()
  41. {
  42. list = new ArrayList ();
  43. }
  44. public FieldNameLookup (DataTable schemaTable)
  45. : this ()
  46. {
  47. foreach (DataRow row in schemaTable.Rows)
  48. list.Add ((string) row["ColumnName"]);
  49. }
  50. #endregion
  51. #region Properties
  52. public int Count {
  53. get { return list.Count; }
  54. }
  55. public bool IsFixedSize {
  56. get { return false; }
  57. }
  58. public bool IsReadOnly {
  59. get { return false; }
  60. }
  61. public bool IsSynchronized {
  62. get { return list.IsSynchronized; }
  63. }
  64. public string this [int index] {
  65. get { return (string) list[index]; }
  66. set { list[index] = value; }
  67. }
  68. public object SyncRoot {
  69. get { return list.SyncRoot; }
  70. }
  71. #endregion
  72. #region Methods
  73. public int Add (object value)
  74. {
  75. return list.Add (value);
  76. }
  77. public void Clear ()
  78. {
  79. list.Clear ();
  80. }
  81. public bool Contains (object value)
  82. {
  83. return list.Contains (value);
  84. }
  85. public void CopyTo (Array array, int index)
  86. {
  87. list.CopyTo (array, index);
  88. }
  89. IEnumerator IEnumerable.GetEnumerator ()
  90. {
  91. return list.GetEnumerator ();
  92. }
  93. public int IndexOf (object value)
  94. {
  95. return list.IndexOf (value);
  96. }
  97. public void Insert (int index, object value)
  98. {
  99. list.Insert (index, value);
  100. }
  101. public void Remove (object value)
  102. {
  103. list.Remove (value);
  104. }
  105. public void RemoveAt (int index)
  106. {
  107. list.RemoveAt (index);
  108. }
  109. #endregion // Methods
  110. }
  111. }