DataColumnMappingCollection.cs 2.8 KB

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