DbParameterCollectionBase.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. // System.Data.ProviderBase.DbParameterCollectionBase
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. #if NET_1_2
  10. using System.Collections;
  11. using System.Data.Common;
  12. namespace System.Data.ProviderBase {
  13. public abstract class DbParameterCollectionBase : DbParameterCollection
  14. {
  15. #region Fields
  16. ArrayList list;
  17. #endregion // Fields
  18. #region Constructors
  19. [MonoTODO]
  20. protected DbParameterCollectionBase ()
  21. {
  22. list = new ArrayList ();
  23. }
  24. #endregion // Constructors
  25. #region Properties
  26. public override int Count {
  27. get { return list.Count; }
  28. }
  29. public override bool IsFixedSize {
  30. get { return list.IsFixedSize; }
  31. }
  32. public override bool IsReadOnly {
  33. get { return list.IsReadOnly; }
  34. }
  35. public override bool IsSynchronized {
  36. get { return list.IsSynchronized; }
  37. }
  38. protected abstract Type ItemType { get; }
  39. [MonoTODO]
  40. protected virtual string ParameterNamePrefix {
  41. get { throw new NotImplementedException (); }
  42. }
  43. public override object SyncRoot {
  44. get { return list.SyncRoot; }
  45. }
  46. #endregion // Properties
  47. #region Methods
  48. [MonoTODO]
  49. public override int Add (object value)
  50. {
  51. ValidateType (value);
  52. throw new NotImplementedException ();
  53. }
  54. public override void AddRange (Array values)
  55. {
  56. foreach (object value in values)
  57. Add (value);
  58. }
  59. [MonoTODO]
  60. protected override int CheckName (string parameterName)
  61. {
  62. throw new NotImplementedException ();
  63. }
  64. public override void Clear ()
  65. {
  66. list.Clear ();
  67. }
  68. public override bool Contains (object value)
  69. {
  70. return list.Contains (value);
  71. }
  72. [MonoTODO]
  73. public override bool Contains (string value)
  74. {
  75. throw new NotImplementedException ();
  76. }
  77. public override void CopyTo (Array array, int index)
  78. {
  79. list.CopyTo (array, index);
  80. }
  81. public override IEnumerator GetEnumerator ()
  82. {
  83. return list.GetEnumerator ();
  84. }
  85. protected override DbParameter GetParameter (int index)
  86. {
  87. return (DbParameter) list [index];
  88. }
  89. public override int IndexOf (object value)
  90. {
  91. return list.IndexOf (value);
  92. }
  93. [MonoTODO]
  94. public override int IndexOf (string parameterName)
  95. {
  96. throw new NotImplementedException ();
  97. }
  98. [MonoTODO]
  99. protected internal static int IndexOf (IEnumerable items, string parameterName)
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. public override void Insert (int index, object value)
  104. {
  105. list.Insert (index, value);
  106. }
  107. [MonoTODO]
  108. protected virtual void OnChange ()
  109. {
  110. throw new NotImplementedException ();
  111. }
  112. public override void Remove (object value)
  113. {
  114. list.Remove (value);
  115. }
  116. public override void RemoveAt (int index)
  117. {
  118. list.RemoveAt (index);
  119. }
  120. [MonoTODO]
  121. public override void RemoveAt (string parameterName)
  122. {
  123. throw new NotImplementedException ();
  124. }
  125. protected override void SetParameter (int index, DbParameter value)
  126. {
  127. list [index] = value;
  128. }
  129. [MonoTODO]
  130. protected virtual void Validate (int index, object value)
  131. {
  132. throw new NotImplementedException ();
  133. }
  134. protected virtual void ValidateType (object value)
  135. {
  136. Type objectType = value.GetType ();
  137. Type itemType = ItemType;
  138. if (objectType != itemType)
  139. {
  140. Type thisType = this.GetType ();
  141. string err = String.Format ("The {0} only accepts non-null {1} type objects, not {2} objects.", thisType.Name, itemType.Name, objectType.Name);
  142. throw new InvalidCastException (err);
  143. }
  144. }
  145. #endregion // Methods
  146. }
  147. }
  148. #endif