DbParameterCollectionBase.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // System.Data.ProviderBase.DbParameterCollectionBase
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. //
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. #if NET_2_0
  32. using System.Collections;
  33. using System.Data.Common;
  34. namespace System.Data.ProviderBase {
  35. public abstract class DbParameterCollectionBase : DbParameterCollection
  36. {
  37. #region Fields
  38. ArrayList list;
  39. #endregion // Fields
  40. #region Constructors
  41. [MonoTODO]
  42. protected DbParameterCollectionBase ()
  43. {
  44. list = new ArrayList ();
  45. }
  46. #endregion // Constructors
  47. #region Properties
  48. public override int Count {
  49. get { return list.Count; }
  50. }
  51. public override bool IsFixedSize {
  52. get { return list.IsFixedSize; }
  53. }
  54. public override bool IsReadOnly {
  55. get { return list.IsReadOnly; }
  56. }
  57. public override bool IsSynchronized {
  58. get { return list.IsSynchronized; }
  59. }
  60. protected abstract Type ItemType { get; }
  61. [MonoTODO]
  62. protected virtual string ParameterNamePrefix {
  63. get { throw new NotImplementedException (); }
  64. }
  65. public override object SyncRoot {
  66. get { return list.SyncRoot; }
  67. }
  68. #endregion // Properties
  69. #region Methods
  70. [MonoTODO]
  71. public override int Add (object value)
  72. {
  73. ValidateType (value);
  74. throw new NotImplementedException ();
  75. }
  76. public override void AddRange (Array values)
  77. {
  78. foreach (object value in values)
  79. Add (value);
  80. }
  81. [MonoTODO]
  82. protected override int CheckName (string parameterName)
  83. {
  84. throw new NotImplementedException ();
  85. }
  86. public override void Clear ()
  87. {
  88. list.Clear ();
  89. }
  90. public override bool Contains (object value)
  91. {
  92. return list.Contains (value);
  93. }
  94. [MonoTODO]
  95. public override bool Contains (string value)
  96. {
  97. throw new NotImplementedException ();
  98. }
  99. public override void CopyTo (Array array, int index)
  100. {
  101. list.CopyTo (array, index);
  102. }
  103. public override IEnumerator GetEnumerator ()
  104. {
  105. return list.GetEnumerator ();
  106. }
  107. protected override DbParameter GetParameter (int index)
  108. {
  109. return (DbParameter) list [index];
  110. }
  111. public override int IndexOf (object value)
  112. {
  113. return list.IndexOf (value);
  114. }
  115. [MonoTODO]
  116. public override int IndexOf (string parameterName)
  117. {
  118. throw new NotImplementedException ();
  119. }
  120. [MonoTODO]
  121. protected internal static int IndexOf (IEnumerable items, string parameterName)
  122. {
  123. throw new NotImplementedException ();
  124. }
  125. public override void Insert (int index, object value)
  126. {
  127. list.Insert (index, value);
  128. }
  129. [MonoTODO]
  130. protected virtual void OnChange ()
  131. {
  132. throw new NotImplementedException ();
  133. }
  134. public override void Remove (object value)
  135. {
  136. list.Remove (value);
  137. }
  138. public override void RemoveAt (int index)
  139. {
  140. list.RemoveAt (index);
  141. }
  142. [MonoTODO]
  143. public override void RemoveAt (string parameterName)
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. protected override void SetParameter (int index, DbParameter value)
  148. {
  149. list [index] = value;
  150. }
  151. [MonoTODO]
  152. protected virtual void Validate (int index, object value)
  153. {
  154. throw new NotImplementedException ();
  155. }
  156. protected virtual void ValidateType (object value)
  157. {
  158. Type objectType = value.GetType ();
  159. Type itemType = ItemType;
  160. if (objectType != itemType)
  161. {
  162. Type thisType = this.GetType ();
  163. string err = String.Format ("The {0} only accepts non-null {1} type objects, not {2} objects.", thisType.Name, itemType.Name, objectType.Name);
  164. throw new InvalidCastException (err);
  165. }
  166. }
  167. #endregion // Methods
  168. }
  169. }
  170. #endif