2
0

DbParameterCollectionBase.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 DbParameterBaseCollection : DbParameterCollection
  36. {
  37. #region Fields
  38. ArrayList list;
  39. #endregion // Fields
  40. #region Constructors
  41. [MonoTODO]
  42. protected DbParameterBaseCollection ()
  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. public override int Add (object value)
  71. {
  72. ValidateType (value);
  73. return list.Add (value);
  74. }
  75. public override void AddRange (Array values)
  76. {
  77. foreach (object value in values)
  78. Add (value);
  79. }
  80. [MonoTODO]
  81. protected override int CheckName (string parameterName)
  82. {
  83. throw new NotImplementedException ();
  84. }
  85. public override void Clear ()
  86. {
  87. list.Clear ();
  88. }
  89. public override bool Contains (object value)
  90. {
  91. return list.Contains (value);
  92. }
  93. [MonoTODO]
  94. public override bool Contains (string value)
  95. {
  96. throw new NotImplementedException ();
  97. }
  98. public override void CopyTo (Array array, int index)
  99. {
  100. list.CopyTo (array, index);
  101. }
  102. public override IEnumerator GetEnumerator ()
  103. {
  104. return list.GetEnumerator ();
  105. }
  106. protected override DbParameter GetParameter (int index)
  107. {
  108. return (DbParameter) list [index];
  109. }
  110. public override int IndexOf (object value)
  111. {
  112. return list.IndexOf (value);
  113. }
  114. [MonoTODO]
  115. public override int IndexOf (string parameterName)
  116. {
  117. throw new NotImplementedException ();
  118. }
  119. [MonoTODO]
  120. protected internal static int IndexOf (IEnumerable items, string parameterName)
  121. {
  122. throw new NotImplementedException ();
  123. }
  124. public override void Insert (int index, object value)
  125. {
  126. list.Insert (index, value);
  127. }
  128. [MonoTODO]
  129. protected virtual void OnChange ()
  130. {
  131. throw new NotImplementedException ();
  132. }
  133. public override void Remove (object value)
  134. {
  135. list.Remove (value);
  136. }
  137. public override void RemoveAt (int index)
  138. {
  139. list.RemoveAt (index);
  140. }
  141. [MonoTODO]
  142. public override void RemoveAt (string parameterName)
  143. {
  144. throw new NotImplementedException ();
  145. }
  146. protected override void SetParameter (int index, DbParameter value)
  147. {
  148. list [index] = value;
  149. }
  150. [MonoTODO]
  151. protected virtual void Validate (int index, object value)
  152. {
  153. throw new NotImplementedException ();
  154. }
  155. protected virtual void ValidateType (object value)
  156. {
  157. Type objectType = value.GetType ();
  158. Type itemType = ItemType;
  159. if (objectType != itemType)
  160. {
  161. Type thisType = this.GetType ();
  162. string err = String.Format ("The {0} only accepts non-null {1} type objects, not {2} objects.", thisType.Name, itemType.Name, objectType.Name);
  163. throw new InvalidCastException (err);
  164. }
  165. }
  166. #endregion // Methods
  167. }
  168. }
  169. #endif