Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial draft of work on being able to customize the bound parameter and data reader value handling. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | customDataTypes |
Files: | files | file ages | folders |
SHA1: |
4508a3be9e3e0bd6f95e9c6277449d5b |
User & Date: | mistachkin 2016-06-18 22:59:54.381 |
Context
2016-06-19
| ||
01:45 | Add 'userData' parameter to callbacks. check-in: f9b89a33af user: mistachkin tags: customDataTypes | |
2016-06-18
| ||
22:59 | Initial draft of work on being able to customize the bound parameter and data reader value handling. check-in: 4508a3be9e user: mistachkin tags: customDataTypes | |
21:34 | Add IsReadOnly method to the SQLiteConnection class. check-in: c4f8b9e65b user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | using System.Collections.Generic; using System.Globalization; using System.ComponentModel; using System.Reflection; using System.Runtime.InteropServices; using System.IO; using System.Text; ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Event data for connection event handlers. /// </summary> public class ConnectionEventArgs : EventArgs | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | using System.Collections.Generic; using System.Globalization; using System.ComponentModel; using System.Reflection; using System.Runtime.InteropServices; using System.IO; using System.Text; ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This class represents a single value to be returned /// from the <see cref="SQLiteDataReader" /> class via /// its <see cref="SQLiteDataReader.GetBoolean" />, /// <see cref="SQLiteDataReader.GetByte" />, /// <see cref="SQLiteDataReader.GetBytes" />, /// <see cref="SQLiteDataReader.GetChar" />, /// <see cref="SQLiteDataReader.GetChars" />, /// <see cref="SQLiteDataReader.GetDateTime" />, /// <see cref="SQLiteDataReader.GetDecimal" />, /// <see cref="SQLiteDataReader.GetDouble" />, /// <see cref="SQLiteDataReader.GetFloat" />, /// <see cref="SQLiteDataReader.GetGuid" />, /// <see cref="SQLiteDataReader.GetInt16" />, /// <see cref="SQLiteDataReader.GetInt32" />, /// <see cref="SQLiteDataReader.GetInt64" />, /// <see cref="SQLiteDataReader.GetString" />, or /// <see cref="SQLiteDataReader.GetValue" /> method. If the value of the /// associated public field of this class is null upon returning from the /// callback, the null value will only be used if the return type for the /// <see cref="SQLiteDataReader" /> method called is not a value type. /// If the value to be returned from the <see cref="SQLiteDataReader" /> /// method is unsuitable (e.g. null with a value type), an exception will /// be thrown. /// </summary> public sealed class SQLiteDataReaderValue { /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetBoolean" /> method -OR- null to /// indicate an error. /// </summary> public bool? BooleanValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetByte" /> method -OR- null to /// indicate an error. /// </summary> public byte? ByteValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetBytes" /> method. /// </summary> public byte[] BytesValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetChar" /> method -OR- null to /// indicate an error. /// </summary> public char? CharValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetChars" /> method. /// </summary> public char[] CharsValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetDateTime" /> method -OR- null to /// indicate an error. /// </summary> public DateTime? DateTimeValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetDecimal" /> method -OR- null to /// indicate an error. /// </summary> public decimal? DecimalValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetDouble" /> method -OR- null to /// indicate an error. /// </summary> public double? DoubleValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetFloat" /> method -OR- null to /// indicate an error. /// </summary> public float? FloatValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetGuid" /> method -OR- null to /// indicate an error. /// </summary> public Guid? GuidValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetInt16" /> method -OR- null to /// indicate an error. /// </summary> public short? Int16Value; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetInt32" /> method -OR- null to /// indicate an error. /// </summary> public int? Int32Value; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetInt64" /> method -OR- null to /// indicate an error. /// </summary> public long? Int64Value; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetString" /> method. /// </summary> public string StringValue; /// <summary> /// The value to be returned from the /// <see cref="SQLiteDataReader.GetValue" /> method. /// </summary> public object Value; } ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This class represents the parameters that are provided /// to the <see cref="SQLiteDataReader.GetBytes" /> and /// <see cref="SQLiteDataReader.GetChars" /> methods, with /// the exception of the column index (provided separately). /// </summary> public class SQLiteReadArrayEventArgs : EventArgs { #region Private Data /// <summary> /// Provides the underlying storage for the /// <see cref="DataOffset" /> property. /// </summary> private long dataOffset; /// <summary> /// Provides the underlying storage for the /// <see cref="ByteBuffer" /> property. /// </summary> private byte[] byteBuffer; /// <summary> /// Provides the underlying storage for the /// <see cref="CharBuffer" /> property. /// </summary> private char[] charBuffer; /// <summary> /// Provides the underlying storage for the /// <see cref="BufferOffset" /> property. /// </summary> private int bufferOffset; /// <summary> /// Provides the underlying storage for the /// <see cref="Length" /> property. /// </summary> private int length; #endregion ///////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class to pass into a user-defined /// callback associated with the <see cref="SQLiteDataReader.GetBytes" /> /// method. /// </summary> /// <param name="dataOffset"> /// The value that was originally specified for the "dataOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> /// <param name="byteBuffer"> /// The value that was originally specified for the "buffer" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> /// method. /// </param> /// <param name="bufferOffset"> /// The value that was originally specified for the "bufferOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> /// <param name="length"> /// The value that was originally specified for the "length" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> internal SQLiteReadArrayEventArgs( long dataOffset, byte[] byteBuffer, int bufferOffset, int length ) { this.dataOffset = dataOffset; this.byteBuffer = byteBuffer; this.bufferOffset = bufferOffset; this.length = length; } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Constructs an instance of this class to pass into a user-defined /// callback associated with the <see cref="SQLiteDataReader.GetChars" /> /// method. /// </summary> /// <param name="dataOffset"> /// The value that was originally specified for the "dataOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> /// <param name="charBuffer"> /// The value that was originally specified for the "buffer" /// parameter to the <see cref="SQLiteDataReader.GetChars" /> /// method. /// </param> /// <param name="bufferOffset"> /// The value that was originally specified for the "bufferOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> /// <param name="length"> /// The value that was originally specified for the "length" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </param> internal SQLiteReadArrayEventArgs( long dataOffset, char[] charBuffer, int bufferOffset, int length ) { this.dataOffset = dataOffset; this.charBuffer = charBuffer; this.bufferOffset = bufferOffset; this.length = length; } #endregion ///////////////////////////////////////////////////////////////////////// #region Public Properties /// <summary> /// The value that was originally specified for the "dataOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </summary> public long DataOffset { get { return dataOffset; } } ///////////////////////////////////////////////////////////////////////// /// <summary> /// The value that was originally specified for the "buffer" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> /// method. /// </summary> public byte[] ByteBuffer { get { return byteBuffer; } } ///////////////////////////////////////////////////////////////////////// /// <summary> /// The value that was originally specified for the "buffer" /// parameter to the <see cref="SQLiteDataReader.GetChars" /> /// method. /// </summary> public char[] CharBuffer { get { return charBuffer; } } ///////////////////////////////////////////////////////////////////////// /// <summary> /// The value that was originally specified for the "bufferOffset" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </summary> public int BufferOffset { get { return bufferOffset; } } ///////////////////////////////////////////////////////////////////////// /// <summary> /// The value that was originally specified for the "length" /// parameter to the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> methods. /// </summary> public int Length { get { return length; } } #endregion } ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This class represents the parameters and return values for the /// <see cref="SQLiteDataReader.GetBoolean" />, /// <see cref="SQLiteDataReader.GetByte" />, /// <see cref="SQLiteDataReader.GetBytes" />, /// <see cref="SQLiteDataReader.GetChar" />, /// <see cref="SQLiteDataReader.GetChars" />, /// <see cref="SQLiteDataReader.GetDateTime" />, /// <see cref="SQLiteDataReader.GetDecimal" />, /// <see cref="SQLiteDataReader.GetDouble" />, /// <see cref="SQLiteDataReader.GetFloat" />, /// <see cref="SQLiteDataReader.GetGuid" />, /// <see cref="SQLiteDataReader.GetInt16" />, /// <see cref="SQLiteDataReader.GetInt32" />, /// <see cref="SQLiteDataReader.GetInt64" />, /// <see cref="SQLiteDataReader.GetString" />, and /// <see cref="SQLiteDataReader.GetValue" /> methods. /// </summary> public class SQLiteReadValueEventArgs : EventArgs { #region Private Data /// <summary> /// Provides the underlying storage for the /// <see cref="ArrayEventArgs" /> property. /// </summary> private SQLiteReadArrayEventArgs arrayEventArgs; /// <summary> /// Provides the underlying storage for the /// <see cref="Value" /> property. /// </summary> private SQLiteDataReaderValue value; #endregion ///////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs a new instance of this class. Depending on the method /// being called, one or both of the parameters may be null. /// </summary> /// <param name="arrayEventArgs"> /// If the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> method is being called, /// this object will contain the parameters for that method. /// </param> /// <param name="value"> /// This will be modified by the callback to contain the return value /// for the called <see cref="SQLiteDataReader" /> method. /// </param> internal SQLiteReadValueEventArgs( SQLiteReadArrayEventArgs arrayEventArgs, SQLiteDataReaderValue value ) { this.arrayEventArgs = arrayEventArgs; this.value = value; } #endregion ///////////////////////////////////////////////////////////////////////// #region Public Properties /// <summary> /// If the <see cref="SQLiteDataReader.GetBytes" /> or /// <see cref="SQLiteDataReader.GetChars" /> method is being called, /// this object will contain the parameters for that method. /// </summary> public SQLiteReadArrayEventArgs ArrayEventArgs { get { return arrayEventArgs; } } ///////////////////////////////////////////////////////////////////////// /// <summary> /// This will be modified by the callback to contain the return value /// for the called <see cref="SQLiteDataReader" /> method. /// </summary> public SQLiteDataReaderValue Value { get { return value; } } #endregion } ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This represents a method that will be called in response to a request to bind a parameter /// to a command. /// </summary> /// <param name="convert"> /// The <see cref="SQLiteConvert" /> instance in use. /// </param> /// <param name="command"> /// The <see cref="SQLiteCommand" /> instance in use. /// </param> /// <param name="flags"> /// The flags associated with the <see cref="SQLiteConnection" /> instance in use. /// </param> /// <param name="parameter"> /// The <see cref="SQLiteParameter" /> instance being bound to the command. /// </param> /// <param name="index"> /// The ordinal of the parameter being bound to the command. /// </param> /// <param name="complete"> /// Non-zero if the default handling for the parameter binding call should be skipped. /// </param> public delegate void SQLiteBindValueCallback( SQLiteConvert convert, SQLiteCommand command, SQLiteConnectionFlags flags, SQLiteParameter parameter, int index, out bool complete ); ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This represents a method that will be called in response to a request to read a value /// from a data reader. /// </summary> /// <param name="convert"> /// The <see cref="SQLiteConvert" /> instance in use. /// </param> /// <param name="dataReader"> /// The <see cref="SQLiteDataReader" /> instance in use. /// </param> /// <param name="flags"> /// The flags associated with the <see cref="SQLiteConnection" /> instance in use. /// </param> /// <param name="eventArgs"> /// The parameter and return type data for the column being read from the data reader. /// </param> /// <param name="index"> /// The zero based index of the column being read from the data reader. /// </param> /// <param name="complete"> /// Non-zero if the default handling for the data reader call should be skipped. If this /// is set to non-zero and the necessary return value is unavailable or unsuitable, an /// exception will be thrown. /// </param> public delegate void SQLiteReadValueCallback( SQLiteConvert convert, SQLiteDataReader dataReader, SQLiteConnectionFlags flags, SQLiteReadValueEventArgs eventArgs, int index, out bool complete ); ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Event data for connection event handlers. /// </summary> public class ConnectionEventArgs : EventArgs |
︙ | ︙ |