DataColumnMappingCollection.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // System.Data.Common.DataColumnCollection
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. //
  7. // (C) Ximian, Inc
  8. //
  9. using System;
  10. using System.Collections;
  11. using System.Data;
  12. namespace System.Data.Common
  13. {
  14. /// <summary>
  15. /// Contains a collection of DataColumnMapping objects. This class cannot be inherited.
  16. /// </summary>
  17. public sealed class DataColumnMappingCollection :
  18. MarshalByRefObject, IColumnMappingCollection, IList,
  19. ICollection, IEnumerable
  20. {
  21. private DataColumnMapping[] mappings = null;
  22. private int size = 0;
  23. public DataColumnMappingCollection () {
  24. }
  25. public int Add (object obj) {
  26. DataColumnMapping[] tmp = new DataColumnMapping[size + 1];
  27. if (size > 0)
  28. Array.Copy (mappings, tmp, size);
  29. size++;
  30. mappings = tmp;
  31. mappings[size - 1] = obj;
  32. return size;
  33. }
  34. public void AddRange (DataColumnMapping[] values) {
  35. DataColumnMapping[] tmp = new DataColumnMapping[size + values.Length];
  36. if (size > 0)
  37. Array.Copy (mappings, tmp, size);
  38. for (int i = 0; i < values.Length; i++) {
  39. tmp[i + size] = values[i];
  40. }
  41. size += values.Length;
  42. mappings = tmp;
  43. }
  44. public void Clear () {
  45. /* FIXME */
  46. for (int i = 0; i < size; i++)
  47. mappings[i] = null;
  48. size = 0;
  49. }
  50. public bool Contains (object obj) {
  51. for (int i = 0; i < size; i++) {
  52. if (obj.Equals (mappings[i]))
  53. return true;
  54. }
  55. return false;
  56. }
  57. public void CopyTo (Array array, int index) {
  58. Array.Copy (mappings, array, size);
  59. }
  60. public DataColumnMapping GetByDataSetColumn (string value) {
  61. for (int i = 0; i < size; i++) {
  62. if (mappings[i].DataSetColumn == value)
  63. return mappings[i];
  64. }
  65. return null;
  66. }
  67. [MonoTODO]
  68. public static DataColumnMapping GetColumnMappingBySchemaAction (
  69. DataColumnMappingCollection columnMappings,
  70. string sourceColumn,
  71. MissingMappingAction mappingAction) {
  72. throw new NotImplementedException ();
  73. }
  74. public int IndexOf (object obj) {
  75. for (int i = 0; i < size; i++) {
  76. if (obj.Equals (mappings[i]))
  77. return i;
  78. }
  79. return -1;
  80. }
  81. public int IndexOfDataSetColumn (string value) {
  82. for (int i = 0; i < size; i++) {
  83. if (mappings[i].DataSetColumn == value)
  84. return i;
  85. }
  86. return -1;
  87. }
  88. [MonoTODO]
  89. public void Insert (int index, object value) {
  90. throw new NotImplementedException ();
  91. }
  92. [MonoTODO]
  93. public void Remove (object value) {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO]
  97. public void RemoveAt (int index) {
  98. throw new NotImplementedException ();
  99. }
  100. public int Count {
  101. get { return size; }
  102. }
  103. public DataColumnMapping this[int index] {
  104. get {
  105. if (index < size)
  106. return mappings[index];
  107. return null;
  108. }
  109. set {
  110. if (index < size)
  111. mappings[index] = value;
  112. }
  113. }
  114. }
  115. }