System.Data.SQLite
Check-in [57b10f46c0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Revise data reader callback handling for the GetBytes / GetChars methods to allow for more (consistent) customization.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | customDataTypes
Files: files | file ages | folders
SHA1: 57b10f46c0de213810f0647ebb8551aa8cea6976
User & Date: mistachkin 2016-06-19 23:20:54
Context
2016-06-20
03:25
Fix typo in the BindValueUserData property. check-in: 9449fba6d8 user: mistachkin tags: customDataTypes
2016-06-19
23:20
Revise data reader callback handling for the GetBytes / GetChars methods to allow for more (consistent) customization. check-in: 57b10f46c0 user: mistachkin tags: customDataTypes
22:25
More comment updates. check-in: b5a21691b4 user: mistachkin tags: customDataTypes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteConnection.cs.

281
282
283
284
285
286
287

288
289
290
291
292
293
294
...
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
      /// 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" />
................................................................................
      /// 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>







>







 







>












>







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
...
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
      /// 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; }
          set { dataOffset = value; }
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// The value that was originally specified for the "buffer"
      /// parameter to the <see cref="SQLiteDataReader.GetBytes" />
................................................................................
      /// 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; }
          set { bufferOffset = value; }
      }

      /////////////////////////////////////////////////////////////////////////

      /// <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; }
          set { length = value; }
      }
      #endregion
  }

  /////////////////////////////////////////////////////////////////////////////////////////////////

  /// <summary>

Changes to System.Data.SQLite/SQLiteDataReader.cs.

575
576
577
578
579
580
581



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
...
663
664
665
666
667
668
669



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
    public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
    {
        CheckDisposed();
        VerifyForGet();

        if ((_flags & SQLiteConnectionFlags.UseConnectionReadValueCallbacks) == SQLiteConnectionFlags.UseConnectionReadValueCallbacks)
        {



            SQLiteDataReaderValue value = new SQLiteDataReaderValue();
            bool complete;

            InvokeReadValueCallback(i, new SQLiteReadValueEventArgs(
                "GetBytes", new SQLiteReadArrayEventArgs(fieldOffset,
                    buffer, bufferoffset, length), value), out complete);

            if (complete)
            {
                byte[] bytes = value.BytesValue;

                if (bytes != null)
                {
                    Array.Copy(bytes, 0, buffer, bufferoffset, length);

#if !PLATFORM_COMPACTFRAMEWORK
                    return bytes.LongLength;
#else
                    return bytes.Length;
#endif
                }
                else
                {
                    return -1;
                }
            }
        }
................................................................................
    public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
    {
        CheckDisposed();
        VerifyForGet();

        if ((_flags & SQLiteConnectionFlags.UseConnectionReadValueCallbacks) == SQLiteConnectionFlags.UseConnectionReadValueCallbacks)
        {



            SQLiteDataReaderValue value = new SQLiteDataReaderValue();
            bool complete;

            InvokeReadValueCallback(i, new SQLiteReadValueEventArgs(
                "GetChars", new SQLiteReadArrayEventArgs(fieldoffset,
                    buffer, bufferoffset, length), value), out complete);

            if (complete)
            {
                char[] chars = value.CharsValue;

                if (chars != null)
                {
                    Array.Copy(chars, 0, buffer, bufferoffset, length);

#if !PLATFORM_COMPACTFRAMEWORK
                    return chars.LongLength;
#else
                    return chars.Length;
#endif
                }
                else
                {
                    return -1;
                }
            }
        }







>
>
>




<
|







|
|
|
|
|
<
<







 







>
>
>




<
|







|
|
|
|
|
<
<







575
576
577
578
579
580
581
582
583
584
585
586
587
588

589
590
591
592
593
594
595
596
597
598
599
600
601


602
603
604
605
606
607
608
...
663
664
665
666
667
668
669
670
671
672
673
674
675
676

677
678
679
680
681
682
683
684
685
686
687
688
689


690
691
692
693
694
695
696
    public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
    {
        CheckDisposed();
        VerifyForGet();

        if ((_flags & SQLiteConnectionFlags.UseConnectionReadValueCallbacks) == SQLiteConnectionFlags.UseConnectionReadValueCallbacks)
        {
            SQLiteReadArrayEventArgs eventArgs = new SQLiteReadArrayEventArgs(
                fieldOffset, buffer, bufferoffset, length);

            SQLiteDataReaderValue value = new SQLiteDataReaderValue();
            bool complete;

            InvokeReadValueCallback(i, new SQLiteReadValueEventArgs(

                "GetBytes", eventArgs, value), out complete);

            if (complete)
            {
                byte[] bytes = value.BytesValue;

                if (bytes != null)
                {
                    Array.Copy(bytes, /* throw */
                        eventArgs.DataOffset, eventArgs.ByteBuffer,
                        eventArgs.BufferOffset, eventArgs.Length);

                    return eventArgs.Length;


                }
                else
                {
                    return -1;
                }
            }
        }
................................................................................
    public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
    {
        CheckDisposed();
        VerifyForGet();

        if ((_flags & SQLiteConnectionFlags.UseConnectionReadValueCallbacks) == SQLiteConnectionFlags.UseConnectionReadValueCallbacks)
        {
            SQLiteReadArrayEventArgs eventArgs = new SQLiteReadArrayEventArgs(
                fieldoffset, buffer, bufferoffset, length);

            SQLiteDataReaderValue value = new SQLiteDataReaderValue();
            bool complete;

            InvokeReadValueCallback(i, new SQLiteReadValueEventArgs(

                "GetChars", eventArgs, value), out complete);

            if (complete)
            {
                char[] chars = value.CharsValue;

                if (chars != null)
                {
                    Array.Copy(chars, /* throw */
                        eventArgs.DataOffset, eventArgs.CharBuffer,
                        eventArgs.BufferOffset, eventArgs.Length);

                    return eventArgs.Length;


                }
                else
                {
                    return -1;
                }
            }
        }