DataColumnMappingCollection.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. Array.Copy (mappings, tmp, size);
  28. size++;
  29. mappings = tmp;
  30. mappings[size - 1] = obj;
  31. return size;
  32. }
  33. public void AddRange (DataColumnMapping[] values) {
  34. DataColumnMapping[] tmp = new DataColumnMapping[size + values.Length];
  35. Array.Copy (mappings, tmp, size);
  36. for (int i = 0; i < values.Length; i++) {
  37. tmp[i + size] = values[i];
  38. }
  39. size += values.Length;
  40. mappings = tmp;
  41. }
  42. public void Clear () {
  43. /* FIXME */
  44. for (int i = 0; i < size; i++)
  45. mappings[i] = null;
  46. size = 0;
  47. }
  48. public bool Contains (object obj) {
  49. for (int i = 0; i < size; i++) {
  50. if (obj.Equals (mappings[i]))
  51. return true;
  52. }
  53. return false;
  54. }
  55. public void CopyTo (Array array, int index) {
  56. DataColumnMapping[] tmp = new DataColumnMapping[size];
  57. Array.Copy (mappings, tmp, size);
  58. }
  59. public DataColumnMapping GetByDataSetColumn (string value) {
  60. for (int i = 0; i < size; i++) {
  61. if (mappings[i].DataSetColumn == value)
  62. return mappings[i];
  63. }
  64. return null;
  65. }
  66. [MonoTODO]
  67. public static DataColumnMapping GetColumnMappingBySchemaAction (
  68. DataColumnMappingCollection columnMappings,
  69. string sourceColumn,
  70. MissingMappingAction mappingAction) {
  71. throw new NotImplementedException ();
  72. }
  73. public int IndexOf (object obj) {
  74. for (int i = 0; i < size; i++) {
  75. if (obj.Equals (mappings[i]))
  76. return i;
  77. }
  78. return -1;
  79. }
  80. public int IndexOfDataSetColumn (string value) {
  81. for (int i = 0; i < size; i++) {
  82. if (mappings[i].DataSetColumn == value)
  83. return i;
  84. }
  85. return -1;
  86. }
  87. [MonoTODO]
  88. public void Insert (int index, object value) {
  89. throw new NotImplementedException ();
  90. }
  91. [MonoTODO]
  92. public void Remove (object value) {
  93. throw new NotImplementedException ();
  94. }
  95. [MonoTODO]
  96. public void RemoveAt (int index) {
  97. throw new NotImplementedException ();
  98. }
  99. public int Count {
  100. get { return size; }
  101. }
  102. public DataColumnMapping this[int index] {
  103. get {
  104. if (value < size)
  105. return mappings[index];
  106. return null;
  107. }
  108. set {
  109. if (value < size)
  110. mappings[index] = value;
  111. }
  112. }
  113. }
  114. }