DataColumnMappingCollection.cs 2.7 KB

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