2
0

DbParameterBase.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //
  2. // System.Data.ProviderBase.DbParameterBase
  3. //
  4. // Author:
  5. // Sureshkumar T ([email protected])
  6. // Tim Coleman ([email protected])
  7. // Boris Kirzner <[email protected]>
  8. //
  9. // Copyright (C) Tim Coleman, 2003
  10. //
  11. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining
  16. // a copy of this software and associated documentation files (the
  17. // "Software"), to deal in the Software without restriction, including
  18. // without limitation the rights to use, copy, modify, merge, publish,
  19. // distribute, sublicense, and/or sell copies of the Software, and to
  20. // permit persons to whom the Software is furnished to do so, subject to
  21. // the following conditions:
  22. //
  23. // The above copyright notice and this permission notice shall be
  24. // included in all copies or substantial portions of the Software.
  25. //
  26. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  30. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  31. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  32. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. //
  34. #if NET_2_0 || TARGET_JVM
  35. using System.Data.Common;
  36. namespace System.Data.ProviderBase {
  37. public abstract class DbParameterBase : DbParameter
  38. {
  39. #region Fields
  40. string _parameterName;
  41. ParameterDirection _direction = ParameterDirection.Input;
  42. int _size;
  43. #if NET_2_0
  44. byte _precision;
  45. byte _scale;
  46. DataRowVersion _sourceVersion;
  47. #endif
  48. object _value;
  49. bool _isNullable;
  50. int _offset;
  51. string _sourceColumn;
  52. DbParameterCollection _parent = null;
  53. #endregion // Fields
  54. #region Constructors
  55. [MonoTODO]
  56. protected DbParameterBase ()
  57. {
  58. }
  59. protected DbParameterBase (DbParameterBase source)
  60. {
  61. if (source == null)
  62. throw ExceptionHelper.ArgumentNull ("source");
  63. source.CopyTo (this);
  64. ICloneable cloneable = source._value as ICloneable;
  65. if (cloneable != null)
  66. _value = cloneable.Clone ();
  67. }
  68. #endregion // Constructors
  69. #region Properties
  70. [MonoTODO]
  71. protected object CoercedValue {
  72. get { throw new NotImplementedException (); }
  73. }
  74. public override ParameterDirection Direction {
  75. get { return _direction; }
  76. set {
  77. if (_direction != value) {
  78. switch (value) {
  79. case ParameterDirection.Input:
  80. case ParameterDirection.Output:
  81. case ParameterDirection.InputOutput:
  82. case ParameterDirection.ReturnValue:
  83. {
  84. PropertyChanging ();
  85. _direction = value;
  86. return;
  87. }
  88. }
  89. throw ExceptionHelper.InvalidParameterDirection (value);
  90. }
  91. }
  92. }
  93. public override bool IsNullable {
  94. get { return _isNullable; }
  95. set { _isNullable = value; }
  96. }
  97. public virtual int Offset {
  98. get { return _offset; }
  99. set { _offset = value; }
  100. }
  101. public override string ParameterName {
  102. get {
  103. if (_parameterName == null)
  104. return String.Empty;
  105. return _parameterName;
  106. }
  107. set {
  108. if (_parameterName != value) {
  109. PropertyChanging ();
  110. _parameterName = value;
  111. }
  112. }
  113. }
  114. public override int Size {
  115. get { return _size; }
  116. set {
  117. if (_size != value) {
  118. if (value < -1)
  119. throw ExceptionHelper.InvalidSizeValue (value);
  120. PropertyChanging ();
  121. _size = value;
  122. }
  123. }
  124. }
  125. public override string SourceColumn {
  126. get {
  127. if (_sourceColumn == null)
  128. return String.Empty;
  129. return _sourceColumn;
  130. }
  131. set { _sourceColumn = value; }
  132. }
  133. #if NET_2_0
  134. public override DataRowVersion SourceVersion {
  135. get { return _sourceVersion; }
  136. set { _sourceVersion = value; }
  137. }
  138. #endif
  139. public override object Value {
  140. get { return _value; }
  141. set { _value = value; }
  142. }
  143. internal DbParameterCollection Parent
  144. {
  145. get { return _parent; }
  146. set { _parent = value; }
  147. }
  148. #endregion // Properties
  149. #region Methods
  150. [MonoTODO]
  151. public virtual void CopyTo (DbParameter destination)
  152. {
  153. if (destination == null)
  154. throw ExceptionHelper.ArgumentNull ("destination");
  155. DbParameterBase t = (DbParameterBase)destination;
  156. t._parameterName = _parameterName;
  157. t._size = _size;
  158. t._offset = _offset;
  159. t._isNullable = _isNullable;
  160. t._sourceColumn = _sourceColumn;
  161. t._direction = _direction;
  162. if (_value is ICloneable)
  163. t._value = ((ICloneable) _value).Clone ();
  164. else
  165. t._value = this._value;
  166. }
  167. public virtual void PropertyChanging ()
  168. {
  169. }
  170. #if NET_2_0
  171. [MonoTODO]
  172. protected void ResetCoercedValue ()
  173. {
  174. throw new NotImplementedException ();
  175. }
  176. [MonoTODO]
  177. protected void ResetScale ()
  178. {
  179. throw new NotImplementedException ();
  180. }
  181. [MonoTODO]
  182. protected void SetCoercedValue ()
  183. {
  184. throw new NotImplementedException ();
  185. }
  186. [MonoTODO]
  187. protected bool ShouldSerializePrecision ()
  188. {
  189. throw new NotImplementedException ();
  190. }
  191. [MonoTODO]
  192. protected bool ShouldSerializeScale ()
  193. {
  194. throw new NotImplementedException ();
  195. }
  196. #endif
  197. protected bool ShouldSerializeSize ()
  198. {
  199. return (_size != 0);
  200. }
  201. #if NET_2_0
  202. [MonoTODO]
  203. public override string ToString ()
  204. {
  205. throw new NotImplementedException ();
  206. }
  207. [MonoTODO]
  208. protected virtual byte ValuePrecision (object value)
  209. {
  210. throw new NotImplementedException ();
  211. }
  212. [MonoTODO]
  213. protected virtual byte ValueScale (object value)
  214. {
  215. throw new NotImplementedException ();
  216. }
  217. [MonoTODO]
  218. protected virtual int ValueSize (object value)
  219. {
  220. throw new NotImplementedException ();
  221. }
  222. #endif
  223. #endregion // Methods
  224. }
  225. }
  226. #endif