0000: 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a /***************
0010: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0020: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0030: 2a 2a 2a 2a 2a 2a 2a 2a 2a 0d 0a 20 2a 20 41 44 *********.. * AD
0040: 4f 2e 4e 45 54 20 32 2e 30 20 44 61 74 61 20 50 O.NET 2.0 Data P
0050: 72 6f 76 69 64 65 72 20 66 6f 72 20 53 51 4c 69 rovider for SQLi
0060: 74 65 20 56 65 72 73 69 6f 6e 20 33 2e 58 0d 0a te Version 3.X..
0070: 20 2a 20 57 72 69 74 74 65 6e 20 62 79 20 52 6f * Written by Ro
0080: 62 65 72 74 20 53 69 6d 70 73 6f 6e 20 28 72 6f bert Simpson (ro
0090: 62 65 72 74 40 62 6c 61 63 6b 63 61 73 74 6c 65 bert@blackcastle
00a0: 73 6f 66 74 2e 63 6f 6d 29 0d 0a 20 2a 0d 0a 20 soft.com).. *..
00b0: 2a 20 52 65 6c 65 61 73 65 64 20 74 6f 20 74 68 * Released to th
00c0: 65 20 70 75 62 6c 69 63 20 64 6f 6d 61 69 6e 2c e public domain,
00d0: 20 75 73 65 20 61 74 20 79 6f 75 72 20 6f 77 6e use at your own
00e0: 20 72 69 73 6b 21 0d 0a 20 2a 2a 2a 2a 2a 2a 2a risk!.. *******
00f0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0100: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0110: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0120: 2a 2f 0d 0a 0d 0a 6e 61 6d 65 73 70 61 63 65 20 */....namespace
0130: 53 79 73 74 65 6d 2e 44 61 74 61 2e 53 51 4c 69 System.Data.SQLi
0140: 74 65 0d 0a 7b 0d 0a 20 20 75 73 69 6e 67 20 53 te..{.. using S
0150: 79 73 74 65 6d 3b 0d 0a 20 20 75 73 69 6e 67 20 ystem;.. using
0160: 53 79 73 74 65 6d 2e 43 6f 6c 6c 65 63 74 69 6f System.Collectio
0170: 6e 73 2e 47 65 6e 65 72 69 63 3b 0d 0a 20 20 75 ns.Generic;.. u
0180: 73 69 6e 67 20 53 79 73 74 65 6d 2e 52 75 6e 74 sing System.Runt
0190: 69 6d 65 2e 49 6e 74 65 72 6f 70 53 65 72 76 69 ime.InteropServi
01a0: 63 65 73 3b 0d 0a 20 20 75 73 69 6e 67 20 53 79 ces;.. using Sy
01b0: 73 74 65 6d 2e 47 6c 6f 62 61 6c 69 7a 61 74 69 stem.Globalizati
01c0: 6f 6e 3b 0d 0a 0d 0a 20 20 2f 2f 2f 20 3c 73 75 on;.... /// <su
01d0: 6d 6d 61 72 79 3e 0d 0a 20 20 2f 2f 2f 20 54 68 mmary>.. /// Th
01e0: 69 73 20 61 62 73 74 72 61 63 74 20 63 6c 61 73 is abstract clas
01f0: 73 20 69 73 20 64 65 73 69 67 6e 65 64 20 74 6f s is designed to
0200: 20 68 61 6e 64 6c 65 20 75 73 65 72 2d 64 65 66 handle user-def
0210: 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e 73 20 65 ined functions e
0220: 61 73 69 6c 79 2e 20 20 41 6e 20 69 6e 73 74 61 asily. An insta
0230: 6e 63 65 20 6f 66 20 74 68 65 20 64 65 72 69 76 nce of the deriv
0240: 65 64 20 63 6c 61 73 73 20 69 73 20 6d 61 64 65 ed class is made
0250: 20 66 6f 72 20 65 61 63 68 0d 0a 20 20 2f 2f 2f for each.. ///
0260: 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f 20 74 connection to t
0270: 68 65 20 64 61 74 61 62 61 73 65 2e 0d 0a 20 20 he database...
0280: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
0290: 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d /// <remarks>.
02a0: 0a 20 20 2f 2f 2f 20 41 6c 74 68 6f 75 67 68 20 . /// Although
02b0: 74 68 65 72 65 20 69 73 20 6f 6e 65 20 69 6e 73 there is one ins
02c0: 74 61 6e 63 65 20 6f 66 20 61 20 63 6c 61 73 73 tance of a class
02d0: 20 64 65 72 69 76 65 64 20 66 72 6f 6d 20 53 51 derived from SQ
02e0: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 70 65 72 LiteFunction per
02f0: 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 database connec
0300: 74 69 6f 6e 2c 20 74 68 65 20 64 65 72 69 76 65 tion, the derive
0310: 64 20 63 6c 61 73 73 20 68 61 73 20 6e 6f 20 61 d class has no a
0320: 63 63 65 73 73 0d 0a 20 20 2f 2f 2f 20 74 6f 20 ccess.. /// to
0330: 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 63 the underlying c
0340: 6f 6e 6e 65 63 74 69 6f 6e 2e 20 20 54 68 69 73 onnection. This
0350: 20 69 73 20 6e 65 63 65 73 73 61 72 79 20 74 6f is necessary to
0360: 20 64 65 74 65 72 20 69 6d 70 6c 65 6d 65 6e 74 deter implement
0370: 65 72 73 20 66 72 6f 6d 20 74 68 69 6e 6b 69 6e ers from thinkin
0380: 67 20 69 74 20 77 6f 75 6c 64 20 62 65 20 61 20 g it would be a
0390: 67 6f 6f 64 20 69 64 65 61 20 74 6f 20 6d 61 6b good idea to mak
03a0: 65 20 64 61 74 61 62 61 73 65 0d 0a 20 20 2f 2f e database.. //
03b0: 2f 20 63 61 6c 6c 73 20 64 75 72 69 6e 67 20 70 / calls during p
03c0: 72 6f 63 65 73 73 69 6e 67 2e 0d 0a 20 20 2f 2f rocessing... //
03d0: 2f 0d 0a 20 20 2f 2f 2f 20 49 74 20 69 73 20 69 /.. /// It is i
03e0: 6d 70 6f 72 74 61 6e 74 20 74 6f 20 64 69 73 74 mportant to dist
03f0: 69 6e 67 75 69 73 68 20 62 65 74 77 65 65 6e 20 inguish between
0400: 61 20 70 65 72 2d 63 6f 6e 6e 65 63 74 69 6f 6e a per-connection
0410: 20 69 6e 73 74 61 6e 63 65 2c 20 61 6e 64 20 61 instance, and a
0420: 20 70 65 72 2d 53 51 4c 20 73 74 61 74 65 6d 65 per-SQL stateme
0430: 6e 74 20 63 6f 6e 74 65 78 74 2e 20 20 4f 6e 65 nt context. One
0440: 20 69 6e 73 74 61 6e 63 65 20 6f 66 20 74 68 69 instance of thi
0450: 73 20 63 6c 61 73 73 0d 0a 20 20 2f 2f 2f 20 73 s class.. /// s
0460: 65 72 76 69 63 65 73 20 61 6c 6c 20 53 51 4c 20 ervices all SQL
0470: 73 74 61 74 65 6d 65 6e 74 73 20 62 65 69 6e 67 statements being
0480: 20 73 74 65 70 70 65 64 20 74 68 72 6f 75 67 68 stepped through
0490: 20 6f 6e 20 74 68 61 74 20 63 6f 6e 6e 65 63 74 on that connect
04a0: 69 6f 6e 2c 20 61 6e 64 20 74 68 65 72 65 20 63 ion, and there c
04b0: 61 6e 20 62 65 20 6d 61 6e 79 2e 20 20 4f 6e 65 an be many. One
04c0: 20 73 68 6f 75 6c 64 20 6e 65 76 65 72 20 73 74 should never st
04d0: 6f 72 65 20 70 65 72 2d 73 74 61 74 65 6d 65 6e ore per-statemen
04e0: 74 0d 0a 20 20 2f 2f 2f 20 69 6e 66 6f 72 6d 61 t.. /// informa
04f0: 74 69 6f 6e 20 69 6e 20 6d 65 6d 62 65 72 20 76 tion in member v
0500: 61 72 69 61 62 6c 65 73 20 6f 66 20 75 73 65 72 ariables of user
0510: 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f -defined functio
0520: 6e 20 63 6c 61 73 73 65 73 2e 0d 0a 20 20 2f 2f n classes... //
0530: 2f 0d 0a 20 20 2f 2f 2f 20 46 6f 72 20 61 67 67 /.. /// For agg
0540: 72 65 67 61 74 65 20 66 75 6e 63 74 69 6f 6e 73 regate functions
0550: 2c 20 61 6c 77 61 79 73 20 63 72 65 61 74 65 20 , always create
0560: 61 6e 64 20 73 74 6f 72 65 20 79 6f 75 72 20 70 and store your p
0570: 65 72 2d 73 74 61 74 65 6d 65 6e 74 20 64 61 74 er-statement dat
0580: 61 20 69 6e 20 74 68 65 20 63 6f 6e 74 65 78 74 a in the context
0590: 44 61 74 61 20 6f 62 6a 65 63 74 20 6f 6e 20 74 Data object on t
05a0: 68 65 20 31 73 74 20 73 74 65 70 2e 20 20 54 68 he 1st step. Th
05b0: 69 73 20 64 61 74 61 20 77 69 6c 6c 0d 0a 20 20 is data will..
05c0: 2f 2f 2f 20 62 65 20 61 75 74 6f 6d 61 74 69 63 /// be automatic
05d0: 61 6c 6c 79 20 66 72 65 65 64 20 66 6f 72 20 79 ally freed for y
05e0: 6f 75 20 28 61 6e 64 20 44 69 73 70 6f 73 65 28 ou (and Dispose(
05f0: 29 20 63 61 6c 6c 65 64 20 69 66 20 74 68 65 20 ) called if the
0600: 69 74 65 6d 20 73 75 70 70 6f 72 74 73 20 49 44 item supports ID
0610: 69 73 70 6f 73 61 62 6c 65 29 20 77 68 65 6e 20 isposable) when
0620: 74 68 65 20 73 74 61 74 65 6d 65 6e 74 20 63 6f the statement co
0630: 6d 70 6c 65 74 65 73 2e 0d 0a 20 20 2f 2f 2f 20 mpletes... ///
0640: 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 70 75 </remarks>.. pu
0650: 62 6c 69 63 20 61 62 73 74 72 61 63 74 20 63 6c blic abstract cl
0660: 61 73 73 20 53 51 4c 69 74 65 46 75 6e 63 74 69 ass SQLiteFuncti
0670: 6f 6e 20 3a 20 49 44 69 73 70 6f 73 61 62 6c 65 on : IDisposable
0680: 0d 0a 20 20 7b 0d 0a 20 20 20 20 70 72 69 76 61 .. {.. priva
0690: 74 65 20 63 6c 61 73 73 20 41 67 67 72 65 67 61 te class Aggrega
06a0: 74 65 44 61 74 61 0d 0a 20 20 20 20 7b 0d 0a 20 teData.. {..
06b0: 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 69 6e internal in
06c0: 74 20 5f 63 6f 75 6e 74 20 3d 20 31 3b 0d 0a 20 t _count = 1;..
06d0: 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 62 internal ob
06e0: 6a 65 63 74 20 5f 64 61 74 61 3b 0d 0a 20 20 20 ject _data;..
06f0: 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f }.... //////
0700: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0710: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0720: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0730: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0740: 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c ///.... /// <
0750: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
0760: 2f 20 54 68 65 20 62 61 73 65 20 63 6f 6e 6e 65 / The base conne
0770: 63 74 69 6f 6e 20 74 68 69 73 20 66 75 6e 63 74 ction this funct
0780: 69 6f 6e 20 69 73 20 61 74 74 61 63 68 65 64 20 ion is attached
0790: 74 6f 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 to.. /// </su
07a0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 69 6e 74 65 mmary>.. inte
07b0: 72 6e 61 6c 20 53 51 4c 69 74 65 42 61 73 65 20 rnal SQLiteBase
07c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 62 61 _ba
07d0: 73 65 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c se;.... /// <
07e0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
07f0: 2f 20 49 6e 74 65 72 6e 61 6c 20 61 72 72 61 79 / Internal array
0800: 20 75 73 65 64 20 74 6f 20 6b 65 65 70 20 74 72 used to keep tr
0810: 61 63 6b 20 6f 66 20 61 67 67 72 65 67 61 74 65 ack of aggregate
0820: 20 66 75 6e 63 74 69 6f 6e 20 63 6f 6e 74 65 78 function contex
0830: 74 20 64 61 74 61 0d 0a 20 20 20 20 2f 2f 2f 20 t data.. ///
0840: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
0850: 70 72 69 76 61 74 65 20 44 69 63 74 69 6f 6e 61 private Dictiona
0860: 72 79 3c 49 6e 74 50 74 72 2c 20 41 67 67 72 65 ry<IntPtr, Aggre
0870: 67 61 74 65 44 61 74 61 3e 20 5f 63 6f 6e 74 65 gateData> _conte
0880: 78 74 44 61 74 61 4c 69 73 74 3b 0d 0a 0d 0a 20 xtDataList;....
0890: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
08a0: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 63 6f .. /// The co
08b0: 6e 6e 65 63 74 69 6f 6e 20 66 6c 61 67 73 20 61 nnection flags a
08c0: 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 ssociated with t
08d0: 68 69 73 20 6f 62 6a 65 63 74 20 28 74 68 69 73 his object (this
08e0: 20 73 68 6f 75 6c 64 20 62 65 20 74 68 65 0d 0a should be the..
08f0: 20 20 20 20 2f 2f 2f 20 73 61 6d 65 20 76 61 6c /// same val
0900: 75 65 20 61 73 20 74 68 65 20 66 6c 61 67 73 20 ue as the flags
0910: 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 associated with
0920: 74 68 65 20 70 61 72 65 6e 74 20 63 6f 6e 6e 65 the parent conne
0930: 63 74 69 6f 6e 20 6f 62 6a 65 63 74 29 2e 0d 0a ction object)...
0940: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
0950: 79 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 y>.. private
0960: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
0970: 46 6c 61 67 73 20 5f 66 6c 61 67 73 3b 0d 0a 0d Flags _flags;...
0980: 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
0990: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 6f 6c 64 y>.. /// Hold
09a0: 73 20 61 20 72 65 66 65 72 65 6e 63 65 20 74 6f s a reference to
09b0: 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 66 75 the callback fu
09c0: 6e 63 74 69 6f 6e 20 66 6f 72 20 75 73 65 72 20 nction for user
09d0: 66 75 6e 63 74 69 6f 6e 73 0d 0a 20 20 20 20 2f functions.. /
09e0: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
09f0: 20 20 20 70 72 69 76 61 74 65 20 53 51 4c 69 74 private SQLit
0a00: 65 43 61 6c 6c 62 61 63 6b 20 20 5f 49 6e 76 6f eCallback _Invo
0a10: 6b 65 46 75 6e 63 3b 0d 0a 20 20 20 20 2f 2f 2f keFunc;.. ///
0a20: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
0a30: 2f 2f 2f 20 48 6f 6c 64 73 20 61 20 72 65 66 65 /// Holds a refe
0a40: 72 65 6e 63 65 20 74 6f 20 74 68 65 20 63 61 6c rence to the cal
0a50: 6c 62 61 6b 63 20 66 75 6e 63 74 69 6f 6e 20 66 lbakc function f
0a60: 6f 72 20 73 74 65 70 70 69 6e 67 20 69 6e 20 61 or stepping in a
0a70: 6e 20 61 67 67 72 65 67 61 74 65 20 66 75 6e 63 n aggregate func
0a80: 74 69 6f 6e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f tion.. /// </
0a90: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 summary>.. pr
0aa0: 69 76 61 74 65 20 53 51 4c 69 74 65 43 61 6c 6c ivate SQLiteCall
0ab0: 62 61 63 6b 20 20 5f 53 74 65 70 46 75 6e 63 3b back _StepFunc;
0ac0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
0ad0: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 6f 6c ry>.. /// Hol
0ae0: 64 73 20 61 20 72 65 66 65 72 65 6e 63 65 20 74 ds a reference t
0af0: 6f 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 66 o the callback f
0b00: 75 6e 63 74 69 6f 6e 20 66 6f 72 20 66 69 6e 61 unction for fina
0b10: 6c 69 7a 69 6e 67 20 61 6e 20 61 67 67 72 65 67 lizing an aggreg
0b20: 61 74 65 20 66 75 6e 63 74 69 6f 6e 0d 0a 20 20 ate function..
0b30: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
0b40: 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 53 51 .. private SQ
0b50: 4c 69 74 65 46 69 6e 61 6c 43 61 6c 6c 62 61 63 LiteFinalCallbac
0b60: 6b 20 20 5f 46 69 6e 61 6c 46 75 6e 63 3b 0d 0a k _FinalFunc;..
0b70: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
0b80: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 6f 6c 64 73 >.. /// Holds
0b90: 20 61 20 72 65 66 65 72 65 6e 63 65 20 74 6f 20 a reference to
0ba0: 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e the callback fun
0bb0: 63 74 69 6f 6e 20 66 6f 72 20 63 6f 6c 6c 61 74 ction for collat
0bc0: 69 6f 6e 20 73 65 71 75 65 6e 63 65 73 0d 0a 20 ion sequences..
0bd0: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
0be0: 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 53 >.. private S
0bf0: 51 4c 69 74 65 43 6f 6c 6c 61 74 69 6f 6e 20 5f QLiteCollation _
0c00: 43 6f 6d 70 61 72 65 46 75 6e 63 3b 0d 0a 0d 0a CompareFunc;....
0c10: 20 20 20 20 70 72 69 76 61 74 65 20 53 51 4c 69 private SQLi
0c20: 74 65 43 6f 6c 6c 61 74 69 6f 6e 20 5f 43 6f 6d teCollation _Com
0c30: 70 61 72 65 46 75 6e 63 31 36 3b 0d 0a 0d 0a 20 pareFunc16;....
0c40: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
0c50: 0d 0a 20 20 20 20 2f 2f 2f 20 43 75 72 72 65 6e .. /// Curren
0c60: 74 20 63 6f 6e 74 65 78 74 20 6f 66 20 74 68 65 t context of the
0c70: 20 63 75 72 72 65 6e 74 20 63 61 6c 6c 62 61 63 current callbac
0c80: 6b 2e 20 20 4f 6e 6c 79 20 76 61 6c 69 64 20 64 k. Only valid d
0c90: 75 72 69 6e 67 20 61 20 63 61 6c 6c 62 61 63 6b uring a callback
0ca0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
0cb0: 61 72 79 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e ary>.. intern
0cc0: 61 6c 20 49 6e 74 50 74 72 20 5f 63 6f 6e 74 65 al IntPtr _conte
0cd0: 78 74 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c xt;.... /// <
0ce0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
0cf0: 2f 20 54 68 69 73 20 73 74 61 74 69 63 20 64 69 / This static di
0d00: 63 74 69 6f 6e 61 72 79 20 63 6f 6e 74 61 69 6e ctionary contain
0d10: 73 20 61 6c 6c 20 74 68 65 20 72 65 67 69 73 74 s all the regist
0d20: 65 72 65 64 20 28 6b 6e 6f 77 6e 29 20 75 73 65 ered (known) use
0d30: 72 2d 64 65 66 69 6e 65 64 0d 0a 20 20 20 20 2f r-defined.. /
0d40: 2f 2f 20 66 75 6e 63 74 69 6f 6e 73 20 64 65 63 // functions dec
0d50: 6c 61 72 65 64 20 75 73 69 6e 67 20 74 68 65 20 lared using the
0d60: 70 72 6f 70 65 72 20 61 74 74 72 69 62 75 74 65 proper attribute
0d70: 73 2e 20 20 54 68 65 20 63 6f 6e 74 61 69 6e 65 s. The containe
0d80: 64 20 64 69 63 74 69 6f 6e 61 72 79 0d 0a 20 20 d dictionary..
0d90: 20 20 2f 2f 2f 20 76 61 6c 75 65 73 20 61 72 65 /// values are
0da0: 20 61 6c 77 61 79 73 20 6e 75 6c 6c 20 61 6e 64 always null and
0db0: 20 61 72 65 20 6e 6f 74 20 63 75 72 72 65 6e 74 are not current
0dc0: 6c 79 20 75 73 65 64 2e 0d 0a 20 20 20 20 2f 2f ly used... //
0dd0: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
0de0: 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 63 private static
0df0: 20 49 44 69 63 74 69 6f 6e 61 72 79 3c 53 51 4c IDictionary<SQL
0e00: 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 iteFunctionAttri
0e10: 62 75 74 65 2c 20 6f 62 6a 65 63 74 3e 20 5f 72 bute, object> _r
0e20: 65 67 69 73 74 65 72 65 64 46 75 6e 63 74 69 6f egisteredFunctio
0e30: 6e 73 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c ns;.... /// <
0e40: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
0e50: 2f 20 49 6e 74 65 72 6e 61 6c 20 63 6f 6e 73 74 / Internal const
0e60: 72 75 63 74 6f 72 2c 20 69 6e 69 74 69 61 6c 69 ructor, initiali
0e70: 7a 65 73 20 74 68 65 20 66 75 6e 63 74 69 6f 6e zes the function
0e80: 27 73 20 69 6e 74 65 72 6e 61 6c 20 76 61 72 69 's internal vari
0e90: 61 62 6c 65 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ables... ///
0ea0: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
0eb0: 70 72 6f 74 65 63 74 65 64 20 53 51 4c 69 74 65 protected SQLite
0ec0: 46 75 6e 63 74 69 6f 6e 28 29 0d 0a 20 20 20 20 Function()..
0ed0: 7b 0d 0a 20 20 20 20 20 20 5f 63 6f 6e 74 65 78 {.. _contex
0ee0: 74 44 61 74 61 4c 69 73 74 20 3d 20 6e 65 77 20 tDataList = new
0ef0: 44 69 63 74 69 6f 6e 61 72 79 3c 49 6e 74 50 74 Dictionary<IntPt
0f00: 72 2c 20 41 67 67 72 65 67 61 74 65 44 61 74 61 r, AggregateData
0f10: 3e 28 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 >();.. }....
0f20: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
0f30: 0d 0a 20 20 20 20 2f 2f 2f 20 43 6f 6e 73 74 72 .. /// Constr
0f40: 75 63 74 73 20 61 6e 20 69 6e 73 74 61 6e 63 65 ucts an instance
0f50: 20 6f 66 20 74 68 69 73 20 63 6c 61 73 73 20 75 of this class u
0f60: 73 69 6e 67 20 74 68 65 20 73 70 65 63 69 66 69 sing the specifi
0f70: 65 64 20 64 61 74 61 2d 74 79 70 65 0d 0a 20 20 ed data-type..
0f80: 20 20 2f 2f 2f 20 63 6f 6e 76 65 72 73 69 6f 6e /// conversion
0f90: 20 70 61 72 61 6d 65 74 65 72 73 2e 0d 0a 20 20 parameters...
0fa0: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
0fb0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
0fc0: 20 6e 61 6d 65 3d 22 66 6f 72 6d 61 74 22 3e 0d name="format">.
0fd0: 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 44 61 74 . /// The Dat
0fe0: 65 54 69 6d 65 20 66 6f 72 6d 61 74 20 74 6f 20 eTime format to
0ff0: 62 65 20 75 73 65 64 20 77 68 65 6e 20 63 6f 6e be used when con
1000: 76 65 72 74 69 6e 67 20 73 74 72 69 6e 67 20 76 verting string v
1010: 61 6c 75 65 73 20 74 6f 20 61 0d 0a 20 20 20 20 alues to a..
1020: 2f 2f 2f 20 44 61 74 65 54 69 6d 65 20 61 6e 64 /// DateTime and
1030: 20 62 69 6e 64 69 6e 67 20 44 61 74 65 54 69 6d binding DateTim
1040: 65 20 70 61 72 61 6d 65 74 65 72 73 2e 0d 0a 20 e parameters...
1050: 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
1060: 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
1070: 6e 61 6d 65 3d 22 6b 69 6e 64 22 3e 0d 0a 20 20 name="kind">..
1080: 20 20 2f 2f 2f 20 54 68 65 20 3c 73 65 65 20 63 /// The <see c
1090: 72 65 66 3d 22 44 61 74 65 54 69 6d 65 4b 69 6e ref="DateTimeKin
10a0: 64 22 20 2f 3e 20 74 6f 20 62 65 20 75 73 65 64 d" /> to be used
10b0: 20 77 68 65 6e 20 63 72 65 61 74 69 6e 67 20 44 when creating D
10c0: 61 74 65 54 69 6d 65 0d 0a 20 20 20 20 2f 2f 2f ateTime.. ///
10d0: 20 76 61 6c 75 65 73 2e 0d 0a 20 20 20 20 2f 2f values... //
10e0: 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 / </param>..
10f0: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
1100: 22 66 6f 72 6d 61 74 53 74 72 69 6e 67 22 3e 0d "formatString">.
1110: 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 66 6f 72 . /// The for
1120: 6d 61 74 20 73 74 72 69 6e 67 20 74 6f 20 62 65 mat string to be
1130: 20 75 73 65 64 20 77 68 65 6e 20 70 61 72 73 69 used when parsi
1140: 6e 67 20 61 6e 64 20 66 6f 72 6d 61 74 74 69 6e ng and formattin
1150: 67 20 44 61 74 65 54 69 6d 65 0d 0a 20 20 20 20 g DateTime..
1160: 2f 2f 2f 20 76 61 6c 75 65 73 2e 0d 0a 20 20 20 /// values...
1170: 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
1180: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
1190: 6d 65 3d 22 75 74 66 31 36 22 3e 0d 0a 20 20 20 me="utf16">..
11a0: 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 74 6f /// Non-zero to
11b0: 20 63 72 65 61 74 65 20 61 20 55 54 46 2d 31 36 create a UTF-16
11c0: 20 64 61 74 61 2d 74 79 70 65 20 63 6f 6e 76 65 data-type conve
11d0: 72 73 69 6f 6e 20 63 6f 6e 74 65 78 74 3b 20 6f rsion context; o
11e0: 74 68 65 72 77 69 73 65 2c 0d 0a 20 20 20 20 2f therwise,.. /
11f0: 2f 2f 20 61 20 55 54 46 2d 38 20 64 61 74 61 2d // a UTF-8 data-
1200: 74 79 70 65 20 63 6f 6e 76 65 72 73 69 6f 6e 20 type conversion
1210: 63 6f 6e 74 65 78 74 20 77 69 6c 6c 20 62 65 20 context will be
1220: 63 72 65 61 74 65 64 2e 0d 0a 20 20 20 20 2f 2f created... //
1230: 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 / </param>..
1240: 70 72 6f 74 65 63 74 65 64 20 53 51 4c 69 74 65 protected SQLite
1250: 46 75 6e 63 74 69 6f 6e 28 0d 0a 20 20 20 20 20 Function(..
1260: 20 20 20 53 51 4c 69 74 65 44 61 74 65 46 6f 72 SQLiteDateFor
1270: 6d 61 74 73 20 66 6f 72 6d 61 74 2c 0d 0a 20 20 mats format,..
1280: 20 20 20 20 20 20 44 61 74 65 54 69 6d 65 4b 69 DateTimeKi
1290: 6e 64 20 6b 69 6e 64 2c 0d 0a 20 20 20 20 20 20 nd kind,..
12a0: 20 20 73 74 72 69 6e 67 20 66 6f 72 6d 61 74 53 string formatS
12b0: 74 72 69 6e 67 2c 0d 0a 20 20 20 20 20 20 20 20 tring,..
12c0: 62 6f 6f 6c 20 75 74 66 31 36 0d 0a 20 20 20 20 bool utf16..
12d0: 20 20 20 20 29 0d 0a 20 20 20 20 20 20 20 20 3a ).. :
12e0: 20 74 68 69 73 28 29 0d 0a 20 20 20 20 7b 0d 0a this().. {..
12f0: 20 20 20 20 20 20 20 20 69 66 20 28 75 74 66 31 if (utf1
1300: 36 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6)..
1310: 5f 62 61 73 65 20 3d 20 6e 65 77 20 53 51 4c 69 _base = new SQLi
1320: 74 65 33 5f 55 54 46 31 36 28 66 6f 72 6d 61 74 te3_UTF16(format
1330: 2c 20 6b 69 6e 64 2c 20 66 6f 72 6d 61 74 53 74 , kind, formatSt
1340: 72 69 6e 67 2c 20 49 6e 74 50 74 72 2e 5a 65 72 ring, IntPtr.Zer
1350: 6f 2c 20 6e 75 6c 6c 2c 20 66 61 6c 73 65 29 3b o, null, false);
1360: 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a .. else..
1370: 20 20 20 20 20 20 20 20 20 20 20 20 5f 62 61 73 _bas
1380: 65 20 3d 20 6e 65 77 20 53 51 4c 69 74 65 33 28 e = new SQLite3(
1390: 66 6f 72 6d 61 74 2c 20 6b 69 6e 64 2c 20 66 6f format, kind, fo
13a0: 72 6d 61 74 53 74 72 69 6e 67 2c 20 49 6e 74 50 rmatString, IntP
13b0: 74 72 2e 5a 65 72 6f 2c 20 6e 75 6c 6c 2c 20 66 tr.Zero, null, f
13c0: 61 6c 73 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d alse);.. }...
13d0: 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f . ///////////
13e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
13f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1400: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1410: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1420: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1430: 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 23 72 65 67 ////.... #reg
1440: 69 6f 6e 20 49 44 69 73 70 6f 73 61 62 6c 65 20 ion IDisposable
1450: 4d 65 6d 62 65 72 73 0d 0a 20 20 20 20 2f 2f 2f Members.. ///
1460: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
1470: 2f 2f 2f 20 44 69 73 70 6f 73 65 73 20 6f 66 20 /// Disposes of
1480: 61 6e 79 20 61 63 74 69 76 65 20 63 6f 6e 74 65 any active conte
1490: 78 74 44 61 74 61 20 76 61 72 69 61 62 6c 65 73 xtData variables
14a0: 20 74 68 61 74 20 77 65 72 65 20 6e 6f 74 20 61 that were not a
14b0: 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 63 6c 65 utomatically cle
14c0: 61 6e 65 64 20 75 70 2e 20 20 53 6f 6d 65 74 69 aned up. Someti
14d0: 6d 65 73 20 74 68 69 73 20 63 61 6e 20 68 61 70 mes this can hap
14e0: 70 65 6e 20 69 66 0d 0a 20 20 20 20 2f 2f 2f 20 pen if.. ///
14f0: 73 6f 6d 65 6f 6e 65 20 63 6c 6f 73 65 73 20 74 someone closes t
1500: 68 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 77 68 he connection wh
1510: 69 6c 65 20 61 20 44 61 74 61 52 65 61 64 65 72 ile a DataReader
1520: 20 69 73 20 6f 70 65 6e 2e 0d 0a 20 20 20 20 2f is open... /
1530: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
1540: 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 44 public void D
1550: 69 73 70 6f 73 65 28 29 0d 0a 20 20 20 20 7b 0d ispose().. {.
1560: 0a 20 20 20 20 20 20 20 20 44 69 73 70 6f 73 65 . Dispose
1570: 28 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 (true);..
1580: 20 47 43 2e 53 75 70 70 72 65 73 73 46 69 6e 61 GC.SuppressFina
1590: 6c 69 7a 65 28 74 68 69 73 29 3b 0d 0a 20 20 20 lize(this);..
15a0: 20 7d 0d 0a 20 20 20 20 23 65 6e 64 72 65 67 69 }.. #endregi
15b0: 6f 6e 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f on.... //////
15c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1600: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1610: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
1620: 20 23 72 65 67 69 6f 6e 20 49 44 69 73 70 6f 73 #region IDispos
1630: 61 62 6c 65 20 22 50 61 74 74 65 72 6e 22 20 4d able "Pattern" M
1640: 65 6d 62 65 72 73 0d 0a 20 20 20 20 70 72 69 76 embers.. priv
1650: 61 74 65 20 62 6f 6f 6c 20 64 69 73 70 6f 73 65 ate bool dispose
1660: 64 3b 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 d;.. private
1670: 76 6f 69 64 20 43 68 65 63 6b 44 69 73 70 6f 73 void CheckDispos
1680: 65 64 28 29 20 2f 2a 20 74 68 72 6f 77 20 2a 2f ed() /* throw */
1690: 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 54 48 52 .. {..#if THR
16a0: 4f 57 5f 4f 4e 5f 44 49 53 50 4f 53 45 44 0d 0a OW_ON_DISPOSED..
16b0: 20 20 20 20 20 20 20 20 69 66 20 28 64 69 73 70 if (disp
16c0: 6f 73 65 64 29 0d 0a 20 20 20 20 20 20 20 20 20 osed)..
16d0: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4f 62 6a throw new Obj
16e0: 65 63 74 44 69 73 70 6f 73 65 64 45 78 63 65 70 ectDisposedExcep
16f0: 74 69 6f 6e 28 74 79 70 65 6f 66 28 53 51 4c 69 tion(typeof(SQLi
1700: 74 65 46 75 6e 63 74 69 6f 6e 29 2e 4e 61 6d 65 teFunction).Name
1710: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
1720: 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f }.... ///////
1730: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1740: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1750: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1760: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1770: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1780: 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 ////////....
1790: 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 /// <summary>..
17a0: 20 20 20 2f 2f 2f 20 50 6c 61 63 65 68 6f 6c 64 /// Placehold
17b0: 65 72 20 66 6f 72 20 61 20 75 73 65 72 2d 64 65 er for a user-de
17c0: 66 69 6e 65 64 20 64 69 73 70 6f 73 61 6c 20 72 fined disposal r
17d0: 6f 75 74 69 6e 65 0d 0a 20 20 20 20 2f 2f 2f 20 outine.. ///
17e0: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
17f0: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
1800: 22 64 69 73 70 6f 73 69 6e 67 22 3e 54 72 75 65 "disposing">True
1810: 20 69 66 20 74 68 65 20 6f 62 6a 65 63 74 20 69 if the object i
1820: 73 20 62 65 69 6e 67 20 64 69 73 70 6f 73 65 64 s being disposed
1830: 20 65 78 70 6c 69 63 69 74 6c 79 3c 2f 70 61 72 explicitly</par
1840: 61 6d 3e 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 am>.. protect
1850: 65 64 20 76 69 72 74 75 61 6c 20 76 6f 69 64 20 ed virtual void
1860: 44 69 73 70 6f 73 65 28 62 6f 6f 6c 20 64 69 73 Dispose(bool dis
1870: 70 6f 73 69 6e 67 29 0d 0a 20 20 20 20 7b 0d 0a posing).. {..
1880: 20 20 20 20 20 20 20 20 69 66 20 28 21 64 69 73 if (!dis
1890: 70 6f 73 65 64 29 0d 0a 20 20 20 20 20 20 20 20 posed)..
18a0: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 {.. i
18b0: 66 20 28 64 69 73 70 6f 73 69 6e 67 29 0d 0a 20 f (disposing)..
18c0: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
18d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
18e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
18f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1900: 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 //..
1910: 20 20 20 20 2f 2f 20 64 69 73 70 6f 73 65 20 6d // dispose m
1920: 61 6e 61 67 65 64 20 72 65 73 6f 75 72 63 65 73 anaged resources
1930: 20 68 65 72 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 here.....
1940: 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f //////
1950: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1960: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a //////////////..
1970: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
1980: 20 20 49 44 69 73 70 6f 73 61 62 6c 65 20 64 69 IDisposable di
1990: 73 70 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 sp;....
19a0: 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 28 foreach (
19b0: 4b 65 79 56 61 6c 75 65 50 61 69 72 3c 49 6e 74 KeyValuePair<Int
19c0: 50 74 72 2c 20 41 67 67 72 65 67 61 74 65 44 61 Ptr, AggregateDa
19d0: 74 61 3e 20 6b 76 20 69 6e 20 5f 63 6f 6e 74 65 ta> kv in _conte
19e0: 78 74 44 61 74 61 4c 69 73 74 29 0d 0a 20 20 20 xtDataList)..
19f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
1a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1a10: 20 20 20 20 64 69 73 70 20 3d 20 6b 76 2e 56 61 disp = kv.Va
1a20: 6c 75 65 2e 5f 64 61 74 61 20 61 73 20 49 44 69 lue._data as IDi
1a30: 73 70 6f 73 61 62 6c 65 3b 0d 0a 20 20 20 20 20 sposable;..
1a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
1a50: 66 20 28 64 69 73 70 20 21 3d 20 6e 75 6c 6c 29 f (disp != null)
1a60: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
1a70: 20 20 20 20 20 20 20 20 20 20 64 69 73 70 2e 44 disp.D
1a80: 69 73 70 6f 73 65 28 29 3b 0d 0a 20 20 20 20 20 ispose();..
1a90: 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
1aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 63 _c
1ab0: 6f 6e 74 65 78 74 44 61 74 61 4c 69 73 74 2e 43 ontextDataList.C
1ac0: 6c 65 61 72 28 29 3b 0d 0a 20 20 20 20 20 20 20 lear();..
1ad0: 20 20 20 20 20 20 20 20 20 5f 63 6f 6e 74 65 78 _contex
1ae0: 74 44 61 74 61 4c 69 73 74 20 3d 20 6e 75 6c 6c tDataList = null
1af0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
1b00: 20 20 20 20 20 5f 66 6c 61 67 73 20 3d 20 53 51 _flags = SQ
1b10: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
1b20: 61 67 73 2e 4e 6f 6e 65 3b 0d 0a 0d 0a 20 20 20 ags.None;....
1b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 49 6e _In
1b40: 76 6f 6b 65 46 75 6e 63 20 3d 20 6e 75 6c 6c 3b vokeFunc = null;
1b50: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
1b60: 20 20 5f 53 74 65 70 46 75 6e 63 20 3d 20 6e 75 _StepFunc = nu
1b70: 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll;..
1b80: 20 20 20 20 20 5f 46 69 6e 61 6c 46 75 6e 63 20 _FinalFunc
1b90: 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 = null;..
1ba0: 20 20 20 20 20 20 20 20 20 5f 43 6f 6d 70 61 72 _Compar
1bb0: 65 46 75 6e 63 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 eFunc = null;..
1bc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f _
1bd0: 62 61 73 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 base = null;..
1be0: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 }....
1bf0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f /////
1c00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c10: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c20: 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f /.. /
1c30: 2f 20 72 65 6c 65 61 73 65 20 75 6e 6d 61 6e 61 / release unmana
1c40: 67 65 64 20 72 65 73 6f 75 72 63 65 73 20 68 65 ged resources he
1c50: 72 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 20 20 20 re.....
1c60: 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f /////////////
1c70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c80: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
1c90: 20 20 20 20 20 20 20 20 20 64 69 73 70 6f 73 65 dispose
1ca0: 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 d = true;..
1cb0: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 }.. }..
1cc0: 20 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 #endregion....
1cd0: 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f /////////////
1ce0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cf0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d10: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d20: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d30: 2f 2f 0d 0a 0d 0a 20 20 20 20 23 72 65 67 69 6f //.... #regio
1d40: 6e 20 44 65 73 74 72 75 63 74 6f 72 0d 0a 20 20 n Destructor..
1d50: 20 20 7e 53 51 4c 69 74 65 46 75 6e 63 74 69 6f ~SQLiteFunctio
1d60: 6e 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 n().. {..
1d70: 20 20 20 20 44 69 73 70 6f 73 65 28 66 61 6c 73 Dispose(fals
1d80: 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 e);.. }..
1d90: 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 #endregion....
1da0: 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f //////////////
1db0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1dc0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1dd0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1de0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1df0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1e00: 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 /.... /// <su
1e10: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
1e20: 52 65 74 75 72 6e 73 20 61 20 72 65 66 65 72 65 Returns a refere
1e30: 6e 63 65 20 74 6f 20 74 68 65 20 75 6e 64 65 72 nce to the under
1e40: 6c 79 69 6e 67 20 63 6f 6e 6e 65 63 74 69 6f 6e lying connection
1e50: 27 73 20 53 51 4c 69 74 65 43 6f 6e 76 65 72 74 's SQLiteConvert
1e60: 20 63 6c 61 73 73 2c 20 77 68 69 63 68 20 63 61 class, which ca
1e70: 6e 20 62 65 20 75 73 65 64 20 74 6f 20 63 6f 6e n be used to con
1e80: 76 65 72 74 0d 0a 20 20 20 20 2f 2f 2f 20 73 74 vert.. /// st
1e90: 72 69 6e 67 73 20 61 6e 64 20 44 61 74 65 54 69 rings and DateTi
1ea0: 6d 65 27 73 20 69 6e 74 6f 20 74 68 65 20 63 75 me's into the cu
1eb0: 72 72 65 6e 74 20 63 6f 6e 6e 65 63 74 69 6f 6e rrent connection
1ec0: 27 73 20 65 6e 63 6f 64 69 6e 67 20 73 63 68 65 's encoding sche
1ed0: 6d 61 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ma... /// </s
1ee0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 75 62 ummary>.. pub
1ef0: 6c 69 63 20 53 51 4c 69 74 65 43 6f 6e 76 65 72 lic SQLiteConver
1f00: 74 20 53 51 4c 69 74 65 43 6f 6e 76 65 72 74 0d t SQLiteConvert.
1f10: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 . {.. ge
1f20: 74 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 t.. {..
1f30: 20 20 20 20 43 68 65 63 6b 44 69 73 70 6f 73 65 CheckDispose
1f40: 64 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 d();.. re
1f50: 74 75 72 6e 20 5f 62 61 73 65 3b 0d 0a 20 20 20 turn _base;..
1f60: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
1f70: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
1f80: 0d 0a 20 20 20 20 2f 2f 2f 20 53 63 61 6c 61 72 .. /// Scalar
1f90: 20 66 75 6e 63 74 69 6f 6e 73 20 6f 76 65 72 72 functions overr
1fa0: 69 64 65 20 74 68 69 73 20 6d 65 74 68 6f 64 20 ide this method
1fb0: 74 6f 20 64 6f 20 74 68 65 69 72 20 6d 61 67 69 to do their magi
1fc0: 63 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 c... /// </su
1fd0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
1fe0: 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f <remarks>.. /
1ff0: 2f 2f 20 50 61 72 61 6d 65 74 65 72 73 20 70 61 // Parameters pa
2000: 73 73 65 64 20 74 6f 20 66 75 6e 63 74 69 6f 6e ssed to function
2010: 73 20 68 61 76 65 20 6f 6e 6c 79 20 61 6e 20 61 s have only an a
2020: 66 66 69 6e 69 74 79 20 66 6f 72 20 61 20 63 65 ffinity for a ce
2030: 72 74 61 69 6e 20 64 61 74 61 20 74 79 70 65 2c rtain data type,
2040: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 75 6e 64 there is no und
2050: 65 72 6c 79 69 6e 67 20 73 63 68 65 6d 61 20 61 erlying schema a
2060: 76 61 69 6c 61 62 6c 65 0d 0a 20 20 20 20 2f 2f vailable.. //
2070: 2f 20 74 6f 20 66 6f 72 63 65 20 74 68 65 6d 20 / to force them
2080: 69 6e 74 6f 20 61 20 63 65 72 74 61 69 6e 20 74 into a certain t
2090: 79 70 65 2e 20 20 54 68 65 72 65 66 6f 72 65 20 ype. Therefore
20a0: 74 68 65 20 6f 6e 6c 79 20 74 79 70 65 73 20 79 the only types y
20b0: 6f 75 20 77 69 6c 6c 20 65 76 65 72 20 73 65 65 ou will ever see
20c0: 20 61 73 20 70 61 72 61 6d 65 74 65 72 73 20 61 as parameters a
20d0: 72 65 0d 0a 20 20 20 20 2f 2f 2f 20 44 42 4e 75 re.. /// DBNu
20e0: 6c 6c 2e 56 61 6c 75 65 2c 20 49 6e 74 36 34 2c ll.Value, Int64,
20f0: 20 44 6f 75 62 6c 65 2c 20 53 74 72 69 6e 67 20 Double, String
2100: 6f 72 20 62 79 74 65 5b 5d 20 61 72 72 61 79 2e or byte[] array.
2110: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 .. /// </rema
2120: 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 rks>.. /// <p
2130: 61 72 61 6d 20 6e 61 6d 65 3d 22 61 72 67 73 22 aram name="args"
2140: 3e 54 68 65 20 61 72 67 75 6d 65 6e 74 73 20 66 >The arguments f
2150: 6f 72 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 74 or the command t
2160: 6f 20 70 72 6f 63 65 73 73 3c 2f 70 61 72 61 6d o process</param
2170: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 >.. /// <retu
2180: 72 6e 73 3e 59 6f 75 20 6d 61 79 20 72 65 74 75 rns>You may retu
2190: 72 6e 20 6d 6f 73 74 20 73 69 6d 70 6c 65 20 74 rn most simple t
21a0: 79 70 65 73 20 61 73 20 61 20 72 65 74 75 72 6e ypes as a return
21b0: 20 76 61 6c 75 65 2c 20 6e 75 6c 6c 20 6f 72 20 value, null or
21c0: 44 42 4e 75 6c 6c 2e 56 61 6c 75 65 20 74 6f 20 DBNull.Value to
21d0: 72 65 74 75 72 6e 20 6e 75 6c 6c 2c 20 44 61 74 return null, Dat
21e0: 65 54 69 6d 65 2c 20 6f 72 0d 0a 20 20 20 20 2f eTime, or.. /
21f0: 2f 2f 20 79 6f 75 20 6d 61 79 20 72 65 74 75 72 // you may retur
2200: 6e 20 61 6e 20 45 78 63 65 70 74 69 6f 6e 2d 64 n an Exception-d
2210: 65 72 69 76 65 64 20 63 6c 61 73 73 20 69 66 20 erived class if
2220: 79 6f 75 20 77 69 73 68 20 74 6f 20 72 65 74 75 you wish to retu
2230: 72 6e 20 61 6e 20 65 72 72 6f 72 20 74 6f 20 53 rn an error to S
2240: 51 4c 69 74 65 2e 20 20 44 6f 20 6e 6f 74 20 61 QLite. Do not a
2250: 63 74 75 61 6c 6c 79 20 74 68 72 6f 77 20 74 68 ctually throw th
2260: 65 20 65 72 72 6f 72 2c 0d 0a 20 20 20 20 2f 2f e error,.. //
2270: 2f 20 6a 75 73 74 20 72 65 74 75 72 6e 20 69 74 / just return it
2280: 21 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 !</returns>..
2290: 20 70 75 62 6c 69 63 20 76 69 72 74 75 61 6c 20 public virtual
22a0: 6f 62 6a 65 63 74 20 49 6e 76 6f 6b 65 28 6f 62 object Invoke(ob
22b0: 6a 65 63 74 5b 5d 20 61 72 67 73 29 0d 0a 20 20 ject[] args)..
22c0: 20 20 7b 0d 0a 20 20 20 20 20 20 43 68 65 63 6b {.. Check
22d0: 44 69 73 70 6f 73 65 64 28 29 3b 0d 0a 20 20 20 Disposed();..
22e0: 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d return null;.
22f0: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
2300: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
2310: 20 2f 2f 2f 20 41 67 67 72 65 67 61 74 65 20 66 /// Aggregate f
2320: 75 6e 63 74 69 6f 6e 73 20 6f 76 65 72 72 69 64 unctions overrid
2330: 65 20 74 68 69 73 20 6d 65 74 68 6f 64 20 74 6f e this method to
2340: 20 64 6f 20 74 68 65 69 72 20 6d 61 67 69 63 2e do their magic.
2350: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
2360: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ary>.. /// <r
2370: 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f emarks>.. ///
2380: 20 54 79 70 69 63 61 6c 6c 79 20 79 6f 75 27 6c Typically you'l
2390: 6c 20 62 65 20 75 70 64 61 74 69 6e 67 20 77 68 l be updating wh
23a0: 61 74 65 76 65 72 20 79 6f 75 27 76 65 20 70 6c atever you've pl
23b0: 61 63 65 64 20 69 6e 20 74 68 65 20 63 6f 6e 74 aced in the cont
23c0: 65 78 74 44 61 74 61 20 66 69 65 6c 64 20 61 6e extData field an
23d0: 64 20 72 65 74 75 72 6e 69 6e 67 20 61 73 20 71 d returning as q
23e0: 75 69 63 6b 6c 79 20 61 73 20 70 6f 73 73 69 62 uickly as possib
23f0: 6c 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 le... /// </r
2400: 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f emarks>.. ///
2410: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 61 72 <param name="ar
2420: 67 73 22 3e 54 68 65 20 61 72 67 75 6d 65 6e 74 gs">The argument
2430: 73 20 66 6f 72 20 74 68 65 20 63 6f 6d 6d 61 6e s for the comman
2440: 64 20 74 6f 20 70 72 6f 63 65 73 73 3c 2f 70 61 d to process</pa
2450: 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ram>.. /// <p
2460: 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 65 70 4e aram name="stepN
2470: 75 6d 62 65 72 22 3e 54 68 65 20 31 2d 62 61 73 umber">The 1-bas
2480: 65 64 20 73 74 65 70 20 6e 75 6d 62 65 72 2e 20 ed step number.
2490: 20 54 68 69 73 20 69 73 20 69 6e 63 72 65 6d 65 This is increme
24a0: 6d 74 65 64 20 65 61 63 68 20 74 69 6d 65 20 74 mted each time t
24b0: 68 65 20 73 74 65 70 20 6d 65 74 68 6f 64 20 69 he step method i
24c0: 73 20 63 61 6c 6c 65 64 2e 3c 2f 70 61 72 61 6d s called.</param
24d0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
24e0: 6d 20 6e 61 6d 65 3d 22 63 6f 6e 74 65 78 74 44 m name="contextD
24f0: 61 74 61 22 3e 41 20 70 6c 61 63 65 68 6f 6c 64 ata">A placehold
2500: 65 72 20 66 6f 72 20 69 6d 70 6c 65 6d 65 6e 74 er for implement
2510: 65 72 73 20 74 6f 20 73 74 6f 72 65 20 63 6f 6e ers to store con
2520: 74 65 78 74 75 61 6c 20 64 61 74 61 20 70 65 72 textual data per
2530: 74 61 69 6e 69 6e 67 20 74 6f 20 74 68 65 20 63 taining to the c
2540: 75 72 72 65 6e 74 20 63 6f 6e 74 65 78 74 2e 3c urrent context.<
2550: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 70 75 62 /param>.. pub
2560: 6c 69 63 20 76 69 72 74 75 61 6c 20 76 6f 69 64 lic virtual void
2570: 20 53 74 65 70 28 6f 62 6a 65 63 74 5b 5d 20 61 Step(object[] a
2580: 72 67 73 2c 20 69 6e 74 20 73 74 65 70 4e 75 6d rgs, int stepNum
2590: 62 65 72 2c 20 72 65 66 20 6f 62 6a 65 63 74 20 ber, ref object
25a0: 63 6f 6e 74 65 78 74 44 61 74 61 29 0d 0a 20 20 contextData)..
25b0: 20 20 7b 0d 0a 20 20 20 20 20 20 43 68 65 63 6b {.. Check
25c0: 44 69 73 70 6f 73 65 64 28 29 3b 0d 0a 20 20 20 Disposed();..
25d0: 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 }.... /// <s
25e0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
25f0: 20 41 67 67 72 65 67 61 74 65 20 66 75 6e 63 74 Aggregate funct
2600: 69 6f 6e 73 20 6f 76 65 72 72 69 64 65 20 74 68 ions override th
2610: 69 73 20 6d 65 74 68 6f 64 20 74 6f 20 66 69 6e is method to fin
2620: 69 73 68 20 74 68 65 69 72 20 61 67 67 72 65 67 ish their aggreg
2630: 61 74 65 20 70 72 6f 63 65 73 73 69 6e 67 2e 0d ate processing..
2640: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
2650: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 ry>.. /// <re
2660: 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 marks>.. ///
2670: 49 66 20 79 6f 75 20 69 6d 70 6c 65 6d 65 6e 74 If you implement
2680: 65 64 20 79 6f 75 72 20 61 67 67 72 65 67 61 74 ed your aggregat
2690: 65 20 66 75 6e 63 74 69 6f 6e 20 70 72 6f 70 65 e function prope
26a0: 72 6c 79 2c 0d 0a 20 20 20 20 2f 2f 2f 20 79 6f rly,.. /// yo
26b0: 75 27 76 65 20 62 65 65 6e 20 72 65 63 6f 72 64 u've been record
26c0: 69 6e 67 20 61 6e 64 20 6b 65 65 70 69 6e 67 20 ing and keeping
26d0: 74 72 61 63 6b 20 6f 66 20 79 6f 75 72 20 64 61 track of your da
26e0: 74 61 20 69 6e 20 74 68 65 20 63 6f 6e 74 65 78 ta in the contex
26f0: 74 44 61 74 61 20 6f 62 6a 65 63 74 20 70 72 6f tData object pro
2700: 76 69 64 65 64 2c 20 61 6e 64 20 6e 6f 77 20 61 vided, and now a
2710: 74 20 74 68 69 73 20 73 74 61 67 65 20 79 6f 75 t this stage you
2720: 20 73 68 6f 75 6c 64 20 68 61 76 65 0d 0a 20 20 should have..
2730: 20 20 2f 2f 2f 20 61 6c 6c 20 74 68 65 20 69 6e /// all the in
2740: 66 6f 72 6d 61 74 69 6f 6e 20 79 6f 75 20 6e 65 formation you ne
2750: 65 64 20 69 6e 20 74 68 65 72 65 20 74 6f 20 66 ed in there to f
2760: 69 67 75 72 65 20 6f 75 74 20 77 68 61 74 20 74 igure out what t
2770: 6f 20 72 65 74 75 72 6e 2e 0d 0a 20 20 20 20 2f o return... /
2780: 2f 2f 20 4e 4f 54 45 3a 20 20 49 74 20 69 73 20 // NOTE: It is
2790: 70 6f 73 73 69 62 6c 65 20 74 6f 20 61 72 72 69 possible to arri
27a0: 76 65 20 68 65 72 65 20 77 69 74 68 6f 75 74 20 ve here without
27b0: 72 65 63 65 69 76 69 6e 67 20 61 20 70 72 65 76 receiving a prev
27c0: 69 6f 75 73 20 63 61 6c 6c 20 74 6f 20 53 74 65 ious call to Ste
27d0: 70 28 29 2c 20 69 6e 20 77 68 69 63 68 20 63 61 p(), in which ca
27e0: 73 65 20 74 68 65 20 63 6f 6e 74 65 78 74 44 61 se the contextDa
27f0: 74 61 20 77 69 6c 6c 0d 0a 20 20 20 20 2f 2f 2f ta will.. ///
2800: 20 62 65 20 6e 75 6c 6c 2e 20 20 54 68 69 73 20 be null. This
2810: 63 61 6e 20 68 61 70 70 65 6e 20 77 68 65 6e 20 can happen when
2820: 6e 6f 20 72 6f 77 73 20 77 65 72 65 20 72 65 74 no rows were ret
2830: 75 72 6e 65 64 2e 20 20 59 6f 75 20 63 61 6e 20 urned. You can
2840: 65 69 74 68 65 72 20 72 65 74 75 72 6e 20 6e 75 either return nu
2850: 6c 6c 2c 20 6f 72 20 30 20 6f 72 20 73 6f 6d 65 ll, or 0 or some
2860: 20 6f 74 68 65 72 20 63 75 73 74 6f 6d 20 72 65 other custom re
2870: 74 75 72 6e 20 76 61 6c 75 65 0d 0a 20 20 20 20 turn value..
2880: 2f 2f 2f 20 69 66 20 74 68 61 74 20 69 73 20 74 /// if that is t
2890: 68 65 20 63 61 73 65 2e 0d 0a 20 20 20 20 2f 2f he case... //
28a0: 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 / </remarks>..
28b0: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
28c0: 65 3d 22 63 6f 6e 74 65 78 74 44 61 74 61 22 3e e="contextData">
28d0: 59 6f 75 72 20 6f 77 6e 20 61 73 73 69 67 6e 65 Your own assigne
28e0: 64 20 63 6f 6e 74 65 78 74 44 61 74 61 2c 20 70 d contextData, p
28f0: 72 6f 76 69 64 65 64 20 66 6f 72 20 79 6f 75 20 rovided for you
2900: 73 6f 20 79 6f 75 20 63 61 6e 20 72 65 74 75 72 so you can retur
2910: 6e 20 79 6f 75 72 20 66 69 6e 61 6c 20 72 65 73 n your final res
2920: 75 6c 74 73 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 ults.</param>..
2930: 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e /// <returns>
2940: 59 6f 75 20 6d 61 79 20 72 65 74 75 72 6e 20 6d You may return m
2950: 6f 73 74 20 73 69 6d 70 6c 65 20 74 79 70 65 73 ost simple types
2960: 20 61 73 20 61 20 72 65 74 75 72 6e 20 76 61 6c as a return val
2970: 75 65 2c 20 6e 75 6c 6c 20 6f 72 20 44 42 4e 75 ue, null or DBNu
2980: 6c 6c 2e 56 61 6c 75 65 20 74 6f 20 72 65 74 75 ll.Value to retu
2990: 72 6e 20 6e 75 6c 6c 2c 20 44 61 74 65 54 69 6d rn null, DateTim
29a0: 65 2c 20 6f 72 0d 0a 20 20 20 20 2f 2f 2f 20 79 e, or.. /// y
29b0: 6f 75 20 6d 61 79 20 72 65 74 75 72 6e 20 61 6e ou may return an
29c0: 20 45 78 63 65 70 74 69 6f 6e 2d 64 65 72 69 76 Exception-deriv
29d0: 65 64 20 63 6c 61 73 73 20 69 66 20 79 6f 75 20 ed class if you
29e0: 77 69 73 68 20 74 6f 20 72 65 74 75 72 6e 20 61 wish to return a
29f0: 6e 20 65 72 72 6f 72 20 74 6f 20 53 51 4c 69 74 n error to SQLit
2a00: 65 2e 20 20 44 6f 20 6e 6f 74 20 61 63 74 75 61 e. Do not actua
2a10: 6c 6c 79 20 74 68 72 6f 77 20 74 68 65 20 65 72 lly throw the er
2a20: 72 6f 72 2c 0d 0a 20 20 20 20 2f 2f 2f 20 6a 75 ror,.. /// ju
2a30: 73 74 20 72 65 74 75 72 6e 20 69 74 21 0d 0a 20 st return it!..
2a40: 20 20 20 2f 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 /// </returns
2a50: 3e 0d 0a 20 20 20 20 70 75 62 6c 69 63 20 76 69 >.. public vi
2a60: 72 74 75 61 6c 20 6f 62 6a 65 63 74 20 46 69 6e rtual object Fin
2a70: 61 6c 28 6f 62 6a 65 63 74 20 63 6f 6e 74 65 78 al(object contex
2a80: 74 44 61 74 61 29 0d 0a 20 20 20 20 7b 0d 0a 20 tData).. {..
2a90: 20 20 20 20 20 43 68 65 63 6b 44 69 73 70 6f 73 CheckDispos
2aa0: 65 64 28 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 ed();.. ret
2ab0: 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 7d urn null;.. }
2ac0: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
2ad0: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 55 mary>.. /// U
2ae0: 73 65 72 2d 64 65 66 69 6e 65 64 20 63 6f 6c 6c ser-defined coll
2af0: 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65 73 20 ation sequences
2b00: 6f 76 65 72 72 69 64 65 20 74 68 69 73 20 6d 65 override this me
2b10: 74 68 6f 64 20 74 6f 20 70 72 6f 76 69 64 65 20 thod to provide
2b20: 61 20 63 75 73 74 6f 6d 20 73 74 72 69 6e 67 20 a custom string
2b30: 73 6f 72 74 69 6e 67 20 61 6c 67 6f 72 69 74 68 sorting algorith
2b40: 6d 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 m... /// </su
2b50: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
2b60: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 61 72 <param name="par
2b70: 61 6d 31 22 3e 54 68 65 20 66 69 72 73 74 20 73 am1">The first s
2b80: 74 72 69 6e 67 20 74 6f 20 63 6f 6d 70 61 72 65 tring to compare
2b90: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
2ba0: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 / <param name="p
2bb0: 61 72 61 6d 32 22 3e 54 68 65 20 73 65 63 6f 6e aram2">The secon
2bc0: 64 20 73 74 72 6e 69 67 20 74 6f 20 63 6f 6d 70 d strnig to comp
2bd0: 61 72 65 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 are</param>..
2be0: 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 31 20 /// <returns>1
2bf0: 69 66 20 70 61 72 61 6d 31 20 69 73 20 67 72 65 if param1 is gre
2c00: 61 74 65 72 20 74 68 61 6e 20 70 61 72 61 6d 32 ater than param2
2c10: 2c 20 30 20 69 66 20 74 68 65 79 20 61 72 65 20 , 0 if they are
2c20: 65 71 75 61 6c 2c 20 6f 72 20 2d 31 20 69 66 20 equal, or -1 if
2c30: 70 61 72 61 6d 31 20 69 73 20 6c 65 73 73 20 74 param1 is less t
2c40: 68 61 6e 20 70 61 72 61 6d 32 3c 2f 72 65 74 75 han param2</retu
2c50: 72 6e 73 3e 0d 0a 20 20 20 20 70 75 62 6c 69 63 rns>.. public
2c60: 20 76 69 72 74 75 61 6c 20 69 6e 74 20 43 6f 6d virtual int Com
2c70: 70 61 72 65 28 73 74 72 69 6e 67 20 70 61 72 61 pare(string para
2c80: 6d 31 2c 20 73 74 72 69 6e 67 20 70 61 72 61 6d m1, string param
2c90: 32 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 2).. {..
2ca0: 20 43 68 65 63 6b 44 69 73 70 6f 73 65 64 28 29 CheckDisposed()
2cb0: 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 ;.. return
2cc0: 30 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 0;.. }....
2cd0: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
2ce0: 20 20 20 20 2f 2f 2f 20 43 6f 6e 76 65 72 74 73 /// Converts
2cf0: 20 61 6e 20 49 6e 74 50 74 72 20 61 72 72 61 79 an IntPtr array
2d00: 20 6f 66 20 63 6f 6e 74 65 78 74 20 61 72 67 75 of context argu
2d10: 6d 65 6e 74 73 20 74 6f 20 61 6e 20 6f 62 6a 65 ments to an obje
2d20: 63 74 20 61 72 72 61 79 20 63 6f 6e 74 61 69 6e ct array contain
2d30: 69 6e 67 20 74 68 65 20 72 65 73 6f 6c 76 65 64 ing the resolved
2d40: 20 70 61 72 61 6d 65 74 65 72 73 20 74 68 65 20 parameters the
2d50: 70 6f 69 6e 74 65 72 73 20 70 6f 69 6e 74 20 74 pointers point t
2d60: 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 o... /// </su
2d70: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
2d80: 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f <remarks>.. /
2d90: 2f 2f 20 50 61 72 61 6d 65 74 65 72 73 20 70 61 // Parameters pa
2da0: 73 73 65 64 20 74 6f 20 66 75 6e 63 74 69 6f 6e ssed to function
2db0: 73 20 68 61 76 65 20 6f 6e 6c 79 20 61 6e 20 61 s have only an a
2dc0: 66 66 69 6e 69 74 79 20 66 6f 72 20 61 20 63 65 ffinity for a ce
2dd0: 72 74 61 69 6e 20 64 61 74 61 20 74 79 70 65 2c rtain data type,
2de0: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 75 6e 64 there is no und
2df0: 65 72 6c 79 69 6e 67 20 73 63 68 65 6d 61 20 61 erlying schema a
2e00: 76 61 69 6c 61 62 6c 65 0d 0a 20 20 20 20 2f 2f vailable.. //
2e10: 2f 20 74 6f 20 66 6f 72 63 65 20 74 68 65 6d 20 / to force them
2e20: 69 6e 74 6f 20 61 20 63 65 72 74 61 69 6e 20 74 into a certain t
2e30: 79 70 65 2e 20 20 54 68 65 72 65 66 6f 72 65 20 ype. Therefore
2e40: 74 68 65 20 6f 6e 6c 79 20 74 79 70 65 73 20 79 the only types y
2e50: 6f 75 20 77 69 6c 6c 20 65 76 65 72 20 73 65 65 ou will ever see
2e60: 20 61 73 20 70 61 72 61 6d 65 74 65 72 73 20 61 as parameters a
2e70: 72 65 0d 0a 20 20 20 20 2f 2f 2f 20 44 42 4e 75 re.. /// DBNu
2e80: 6c 6c 2e 56 61 6c 75 65 2c 20 49 6e 74 36 34 2c ll.Value, Int64,
2e90: 20 44 6f 75 62 6c 65 2c 20 53 74 72 69 6e 67 20 Double, String
2ea0: 6f 72 20 62 79 74 65 5b 5d 20 61 72 72 61 79 2e or byte[] array.
2eb0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 .. /// </rema
2ec0: 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 rks>.. /// <p
2ed0: 61 72 61 6d 20 6e 61 6d 65 3d 22 6e 41 72 67 73 aram name="nArgs
2ee0: 22 3e 54 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 ">The number of
2ef0: 61 72 67 75 6d 65 6e 74 73 3c 2f 70 61 72 61 6d arguments</param
2f00: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
2f10: 6d 20 6e 61 6d 65 3d 22 61 72 67 73 70 74 72 22 m name="argsptr"
2f20: 3e 41 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 >A pointer to th
2f30: 65 20 61 72 72 61 79 20 6f 66 20 61 72 67 75 6d e array of argum
2f40: 65 6e 74 73 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 ents</param>..
2f50: 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 41 /// <returns>A
2f60: 6e 20 6f 62 6a 65 63 74 20 61 72 72 61 79 20 6f n object array o
2f70: 66 20 74 68 65 20 61 72 67 75 6d 65 6e 74 73 20 f the arguments
2f80: 6f 6e 63 65 20 74 68 65 79 27 76 65 20 62 65 65 once they've bee
2f90: 6e 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 2e n converted to .
2fa0: 4e 45 54 20 76 61 6c 75 65 73 3c 2f 72 65 74 75 NET values</retu
2fb0: 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e rns>.. intern
2fc0: 61 6c 20 6f 62 6a 65 63 74 5b 5d 20 43 6f 6e 76 al object[] Conv
2fd0: 65 72 74 50 61 72 61 6d 73 28 69 6e 74 20 6e 41 ertParams(int nA
2fe0: 72 67 73 2c 20 49 6e 74 50 74 72 20 61 72 67 73 rgs, IntPtr args
2ff0: 70 74 72 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ptr).. {..
3000: 20 20 20 6f 62 6a 65 63 74 5b 5d 20 70 61 72 6d object[] parm
3010: 73 20 3d 20 6e 65 77 20 6f 62 6a 65 63 74 5b 6e s = new object[n
3020: 41 72 67 73 5d 3b 0d 0a 23 69 66 20 21 50 4c 41 Args];..#if !PLA
3030: 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 TFORM_COMPACTFRA
3040: 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 49 6e MEWORK.. In
3050: 74 50 74 72 5b 5d 20 61 72 67 69 6e 74 20 3d 20 tPtr[] argint =
3060: 6e 65 77 20 49 6e 74 50 74 72 5b 6e 41 72 67 73 new IntPtr[nArgs
3070: 5d 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 ];..#else..
3080: 20 69 6e 74 5b 5d 20 61 72 67 69 6e 74 20 3d 20 int[] argint =
3090: 6e 65 77 20 69 6e 74 5b 6e 41 72 67 73 5d 3b 0d new int[nArgs];.
30a0: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 4d .#endif.. M
30b0: 61 72 73 68 61 6c 2e 43 6f 70 79 28 61 72 67 73 arshal.Copy(args
30c0: 70 74 72 2c 20 61 72 67 69 6e 74 2c 20 30 2c 20 ptr, argint, 0,
30d0: 6e 41 72 67 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 nArgs);....
30e0: 20 66 6f 72 20 28 69 6e 74 20 6e 20 3d 20 30 3b for (int n = 0;
30f0: 20 6e 20 3c 20 6e 41 72 67 73 3b 20 6e 2b 2b 29 n < nArgs; n++)
3100: 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 .. {..
3110: 20 20 20 73 77 69 74 63 68 20 28 5f 62 61 73 65 switch (_base
3120: 2e 47 65 74 50 61 72 61 6d 56 61 6c 75 65 54 79 .GetParamValueTy
3130: 70 65 28 28 49 6e 74 50 74 72 29 61 72 67 69 6e pe((IntPtr)argin
3140: 74 5b 6e 5d 29 29 0d 0a 20 20 20 20 20 20 20 20 t[n]))..
3150: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 63 61 73 {.. cas
3160: 65 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 4e e TypeAffinity.N
3170: 75 6c 6c 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 ull:..
3180: 20 20 70 61 72 6d 73 5b 6e 5d 20 3d 20 44 42 4e parms[n] = DBN
3190: 75 6c 6c 2e 56 61 6c 75 65 3b 0d 0a 20 20 20 20 ull.Value;..
31a0: 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a break;..
31b0: 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 54 case T
31c0: 79 70 65 41 66 66 69 6e 69 74 79 2e 49 6e 74 36 ypeAffinity.Int6
31d0: 34 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4:..
31e0: 70 61 72 6d 73 5b 6e 5d 20 3d 20 5f 62 61 73 65 parms[n] = _base
31f0: 2e 47 65 74 50 61 72 61 6d 56 61 6c 75 65 49 6e .GetParamValueIn
3200: 74 36 34 28 28 49 6e 74 50 74 72 29 61 72 67 69 t64((IntPtr)argi
3210: 6e 74 5b 6e 5d 29 3b 0d 0a 20 20 20 20 20 20 20 nt[n]);..
3220: 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 break;..
3230: 20 20 20 20 20 20 20 63 61 73 65 20 54 79 70 65 case Type
3240: 41 66 66 69 6e 69 74 79 2e 44 6f 75 62 6c 65 3a Affinity.Double:
3250: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 61 .. pa
3260: 72 6d 73 5b 6e 5d 20 3d 20 5f 62 61 73 65 2e 47 rms[n] = _base.G
3270: 65 74 50 61 72 61 6d 56 61 6c 75 65 44 6f 75 62 etParamValueDoub
3280: 6c 65 28 28 49 6e 74 50 74 72 29 61 72 67 69 6e le((IntPtr)argin
3290: 74 5b 6e 5d 29 3b 0d 0a 20 20 20 20 20 20 20 20 t[n]);..
32a0: 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 break;..
32b0: 20 20 20 20 20 20 63 61 73 65 20 54 79 70 65 41 case TypeA
32c0: 66 66 69 6e 69 74 79 2e 54 65 78 74 3a 0d 0a 20 ffinity.Text:..
32d0: 20 20 20 20 20 20 20 20 20 20 20 70 61 72 6d 73 parms
32e0: 5b 6e 5d 20 3d 20 5f 62 61 73 65 2e 47 65 74 50 [n] = _base.GetP
32f0: 61 72 61 6d 56 61 6c 75 65 54 65 78 74 28 28 49 aramValueText((I
3300: 6e 74 50 74 72 29 61 72 67 69 6e 74 5b 6e 5d 29 ntPtr)argint[n])
3310: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 62 ;.. b
3320: 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 reak;..
3330: 20 63 61 73 65 20 54 79 70 65 41 66 66 69 6e 69 case TypeAffini
3340: 74 79 2e 42 6c 6f 62 3a 0d 0a 20 20 20 20 20 20 ty.Blob:..
3350: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
3360: 20 20 20 20 20 20 20 69 6e 74 20 78 3b 0d 0a 20 int x;..
3370: 20 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 byt
3380: 65 5b 5d 20 62 6c 6f 62 3b 0d 0a 0d 0a 20 20 20 e[] blob;....
3390: 20 20 20 20 20 20 20 20 20 20 20 78 20 3d 20 28 x = (
33a0: 69 6e 74 29 5f 62 61 73 65 2e 47 65 74 50 61 72 int)_base.GetPar
33b0: 61 6d 56 61 6c 75 65 42 79 74 65 73 28 28 49 6e amValueBytes((In
33c0: 74 50 74 72 29 61 72 67 69 6e 74 5b 6e 5d 2c 20 tPtr)argint[n],
33d0: 30 2c 20 6e 75 6c 6c 2c 20 30 2c 20 30 29 3b 0d 0, null, 0, 0);.
33e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 . b
33f0: 6c 6f 62 20 3d 20 6e 65 77 20 62 79 74 65 5b 78 lob = new byte[x
3400: 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ];..
3410: 20 20 5f 62 61 73 65 2e 47 65 74 50 61 72 61 6d _base.GetParam
3420: 56 61 6c 75 65 42 79 74 65 73 28 28 49 6e 74 50 ValueBytes((IntP
3430: 74 72 29 61 72 67 69 6e 74 5b 6e 5d 2c 20 30 2c tr)argint[n], 0,
3440: 20 62 6c 6f 62 2c 20 30 2c 20 78 29 3b 0d 0a 20 blob, 0, x);..
3450: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 61 72 par
3460: 6d 73 5b 6e 5d 20 3d 20 62 6c 6f 62 3b 0d 0a 20 ms[n] = blob;..
3470: 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
3480: 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b break;
3490: 0d 0a 20 20 20 20 20 20 20 20 20 20 63 61 73 65 .. case
34a0: 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 44 61 TypeAffinity.Da
34b0: 74 65 54 69 6d 65 3a 20 2f 2f 20 4e 65 76 65 72 teTime: // Never
34c0: 20 68 61 70 70 65 6e 73 20 68 65 72 65 20 62 75 happens here bu
34d0: 74 20 77 68 61 74 20 74 68 65 20 68 65 63 6b 2c t what the heck,
34e0: 20 6d 61 79 62 65 20 69 74 20 77 69 6c 6c 20 6f maybe it will o
34f0: 6e 65 20 64 61 79 2e 0d 0a 20 20 20 20 20 20 20 ne day...
3500: 20 20 20 20 20 70 61 72 6d 73 5b 6e 5d 20 3d 20 parms[n] =
3510: 5f 62 61 73 65 2e 54 6f 44 61 74 65 54 69 6d 65 _base.ToDateTime
3520: 28 5f 62 61 73 65 2e 47 65 74 50 61 72 61 6d 56 (_base.GetParamV
3530: 61 6c 75 65 54 65 78 74 28 28 49 6e 74 50 74 72 alueText((IntPtr
3540: 29 61 72 67 69 6e 74 5b 6e 5d 29 29 3b 0d 0a 20 )argint[n]));..
3550: 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b break
3560: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;.. }..
3570: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 72 65 74 }.. ret
3580: 75 72 6e 20 70 61 72 6d 73 3b 0d 0a 20 20 20 20 urn parms;..
3590: 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 }.... /// <su
35a0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
35b0: 54 61 6b 65 73 20 74 68 65 20 72 65 74 75 72 6e Takes the return
35c0: 20 76 61 6c 75 65 20 66 72 6f 6d 20 49 6e 76 6f value from Invo
35d0: 6b 65 28 29 20 61 6e 64 20 46 69 6e 61 6c 28 29 ke() and Final()
35e0: 20 61 6e 64 20 66 69 67 75 72 65 73 20 6f 75 74 and figures out
35f0: 20 68 6f 77 20 74 6f 20 72 65 74 75 72 6e 20 69 how to return i
3600: 74 20 74 6f 20 53 51 4c 69 74 65 27 73 20 63 6f t to SQLite's co
3610: 6e 74 65 78 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ntext... ///
3620: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
3630: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
3640: 22 63 6f 6e 74 65 78 74 22 3e 54 68 65 20 63 6f "context">The co
3650: 6e 74 65 78 74 20 74 68 65 20 72 65 74 75 72 6e ntext the return
3660: 20 76 61 6c 75 65 20 61 70 70 6c 69 65 73 20 74 value applies t
3670: 6f 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f o</param>.. /
3680: 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
3690: 72 65 74 75 72 6e 56 61 6c 75 65 22 3e 54 68 65 returnValue">The
36a0: 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 72 65 parameter to re
36b0: 74 75 72 6e 20 74 6f 20 53 51 4c 69 74 65 3c 2f turn to SQLite</
36c0: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 70 72 69 76 param>.. priv
36d0: 61 74 65 20 76 6f 69 64 20 53 65 74 52 65 74 75 ate void SetRetu
36e0: 72 6e 56 61 6c 75 65 28 49 6e 74 50 74 72 20 63 rnValue(IntPtr c
36f0: 6f 6e 74 65 78 74 2c 20 6f 62 6a 65 63 74 20 72 ontext, object r
3700: 65 74 75 72 6e 56 61 6c 75 65 29 0d 0a 20 20 20 eturnValue)..
3710: 20 7b 0d 0a 20 20 20 20 20 20 69 66 20 28 72 65 {.. if (re
3720: 74 75 72 6e 56 61 6c 75 65 20 3d 3d 20 6e 75 6c turnValue == nul
3730: 6c 20 7c 7c 20 72 65 74 75 72 6e 56 61 6c 75 65 l || returnValue
3740: 20 3d 3d 20 44 42 4e 75 6c 6c 2e 56 61 6c 75 65 == DBNull.Value
3750: 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ).. {..
3760: 20 20 20 20 5f 62 61 73 65 2e 52 65 74 75 72 6e _base.Return
3770: 4e 75 6c 6c 28 63 6f 6e 74 65 78 74 29 3b 0d 0a Null(context);..
3780: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d return;.
3790: 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 . }....
37a0: 20 20 54 79 70 65 20 74 20 3d 20 72 65 74 75 72 Type t = retur
37b0: 6e 56 61 6c 75 65 2e 47 65 74 54 79 70 65 28 29 nValue.GetType()
37c0: 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 74 20 3d ;.. if (t =
37d0: 3d 20 74 79 70 65 6f 66 28 44 61 74 65 54 69 6d = typeof(DateTim
37e0: 65 29 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 e)).. {..
37f0: 20 20 20 20 20 20 5f 62 61 73 65 2e 52 65 74 75 _base.Retu
3800: 72 6e 54 65 78 74 28 63 6f 6e 74 65 78 74 2c 20 rnText(context,
3810: 5f 62 61 73 65 2e 54 6f 53 74 72 69 6e 67 28 28 _base.ToString((
3820: 44 61 74 65 54 69 6d 65 29 72 65 74 75 72 6e 56 DateTime)returnV
3830: 61 6c 75 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 alue));..
3840: 20 72 65 74 75 72 6e 3b 0d 0a 20 20 20 20 20 20 return;..
3850: 7d 0d 0a 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 }.. else..
3860: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
3870: 45 78 63 65 70 74 69 6f 6e 20 72 20 3d 20 72 65 Exception r = re
3880: 74 75 72 6e 56 61 6c 75 65 20 61 73 20 45 78 63 turnValue as Exc
3890: 65 70 74 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 eption;....
38a0: 20 20 20 69 66 20 28 72 20 21 3d 20 6e 75 6c 6c if (r != null
38b0: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
38c0: 20 20 20 20 20 20 20 20 5f 62 61 73 65 2e 52 65 _base.Re
38d0: 74 75 72 6e 45 72 72 6f 72 28 63 6f 6e 74 65 78 turnError(contex
38e0: 74 2c 20 72 2e 4d 65 73 73 61 67 65 29 3b 0d 0a t, r.Message);..
38f0: 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
3900: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;.. }..
3910: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 73 }.... s
3920: 77 69 74 63 68 20 28 53 51 4c 69 74 65 43 6f 6e witch (SQLiteCon
3930: 76 65 72 74 2e 54 79 70 65 54 6f 41 66 66 69 6e vert.TypeToAffin
3940: 69 74 79 28 74 29 29 0d 0a 20 20 20 20 20 20 7b ity(t)).. {
3950: 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 54 .. case T
3960: 79 70 65 41 66 66 69 6e 69 74 79 2e 4e 75 6c 6c ypeAffinity.Null
3970: 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 5f 62 61 :.. _ba
3980: 73 65 2e 52 65 74 75 72 6e 4e 75 6c 6c 28 63 6f se.ReturnNull(co
3990: 6e 74 65 78 74 29 3b 0d 0a 20 20 20 20 20 20 20 ntext);..
39a0: 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 20 20 return;..
39b0: 20 20 20 20 63 61 73 65 20 54 79 70 65 41 66 66 case TypeAff
39c0: 69 6e 69 74 79 2e 49 6e 74 36 34 3a 0d 0a 20 20 inity.Int64:..
39d0: 20 20 20 20 20 20 20 20 5f 62 61 73 65 2e 52 65 _base.Re
39e0: 74 75 72 6e 49 6e 74 36 34 28 63 6f 6e 74 65 78 turnInt64(contex
39f0: 74 2c 20 43 6f 6e 76 65 72 74 2e 54 6f 49 6e 74 t, Convert.ToInt
3a00: 36 34 28 72 65 74 75 72 6e 56 61 6c 75 65 2c 20 64(returnValue,
3a10: 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
3a20: 65 6e 74 43 75 6c 74 75 72 65 29 29 3b 0d 0a 20 entCulture));..
3a30: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b return;
3a40: 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 54 .. case T
3a50: 79 70 65 41 66 66 69 6e 69 74 79 2e 44 6f 75 62 ypeAffinity.Doub
3a60: 6c 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 5f le:.. _
3a70: 62 61 73 65 2e 52 65 74 75 72 6e 44 6f 75 62 6c base.ReturnDoubl
3a80: 65 28 63 6f 6e 74 65 78 74 2c 20 43 6f 6e 76 65 e(context, Conve
3a90: 72 74 2e 54 6f 44 6f 75 62 6c 65 28 72 65 74 75 rt.ToDouble(retu
3aa0: 72 6e 56 61 6c 75 65 2c 20 43 75 6c 74 75 72 65 rnValue, Culture
3ab0: 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 Info.CurrentCult
3ac0: 75 72 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 ure));..
3ad0: 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 20 20 20 return;..
3ae0: 20 20 20 63 61 73 65 20 54 79 70 65 41 66 66 69 case TypeAffi
3af0: 6e 69 74 79 2e 54 65 78 74 3a 0d 0a 20 20 20 20 nity.Text:..
3b00: 20 20 20 20 20 20 5f 62 61 73 65 2e 52 65 74 75 _base.Retu
3b10: 72 6e 54 65 78 74 28 63 6f 6e 74 65 78 74 2c 20 rnText(context,
3b20: 72 65 74 75 72 6e 56 61 6c 75 65 2e 54 6f 53 74 returnValue.ToSt
3b30: 72 69 6e 67 28 29 29 3b 0d 0a 20 20 20 20 20 20 ring());..
3b40: 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 20 return;..
3b50: 20 20 20 20 20 63 61 73 65 20 54 79 70 65 41 66 case TypeAf
3b60: 66 69 6e 69 74 79 2e 42 6c 6f 62 3a 0d 0a 20 20 finity.Blob:..
3b70: 20 20 20 20 20 20 20 20 5f 62 61 73 65 2e 52 65 _base.Re
3b80: 74 75 72 6e 42 6c 6f 62 28 63 6f 6e 74 65 78 74 turnBlob(context
3b90: 2c 20 28 62 79 74 65 5b 5d 29 72 65 74 75 72 6e , (byte[])return
3ba0: 56 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 Value);..
3bb0: 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 20 20 return;..
3bc0: 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 }.. }....
3bd0: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
3be0: 0a 20 20 20 20 2f 2f 2f 20 49 6e 74 65 72 6e 61 . /// Interna
3bf0: 6c 20 73 63 61 6c 61 72 20 63 61 6c 6c 62 61 63 l scalar callbac
3c00: 6b 20 66 75 6e 63 74 69 6f 6e 2c 20 77 68 69 63 k function, whic
3c10: 68 20 77 72 61 70 73 20 74 68 65 20 72 61 77 20 h wraps the raw
3c20: 63 6f 6e 74 65 78 74 20 70 6f 69 6e 74 65 72 20 context pointer
3c30: 61 6e 64 20 63 61 6c 6c 73 20 74 68 65 20 76 69 and calls the vi
3c40: 72 74 75 61 6c 20 49 6e 76 6f 6b 65 28 29 20 6d rtual Invoke() m
3c50: 65 74 68 6f 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ethod... ///
3c60: 57 41 52 4e 49 4e 47 3a 20 4d 75 73 74 20 6e 6f WARNING: Must no
3c70: 74 20 74 68 72 6f 77 20 65 78 63 65 70 74 69 6f t throw exceptio
3c80: 6e 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ns... /// </s
3c90: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
3ca0: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 63 6f <param name="co
3cb0: 6e 74 65 78 74 22 3e 41 20 72 61 77 20 63 6f 6e ntext">A raw con
3cc0: 74 65 78 74 20 70 6f 69 6e 74 65 72 3c 2f 70 61 text pointer</pa
3cd0: 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ram>.. /// <p
3ce0: 61 72 61 6d 20 6e 61 6d 65 3d 22 6e 41 72 67 73 aram name="nArgs
3cf0: 22 3e 4e 75 6d 62 65 72 20 6f 66 20 61 72 67 75 ">Number of argu
3d00: 6d 65 6e 74 73 20 70 61 73 73 65 64 20 69 6e 3c ments passed in<
3d10: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
3d20: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 61 72 <param name="ar
3d30: 67 73 70 74 72 22 3e 41 20 70 6f 69 6e 74 65 72 gsptr">A pointer
3d40: 20 74 6f 20 74 68 65 20 61 72 72 61 79 20 6f 66 to the array of
3d50: 20 61 72 67 75 6d 65 6e 74 73 3c 2f 70 61 72 61 arguments</para
3d60: 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c m>.. internal
3d70: 20 76 6f 69 64 20 53 63 61 6c 61 72 43 61 6c 6c void ScalarCall
3d80: 62 61 63 6b 28 49 6e 74 50 74 72 20 63 6f 6e 74 back(IntPtr cont
3d90: 65 78 74 2c 20 69 6e 74 20 6e 41 72 67 73 2c 20 ext, int nArgs,
3da0: 49 6e 74 50 74 72 20 61 72 67 73 70 74 72 29 0d IntPtr argsptr).
3db0: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
3dc0: 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a try.. {..
3dd0: 20 20 20 20 20 20 20 20 20 20 20 20 5f 63 6f 6e _con
3de0: 74 65 78 74 20 3d 20 63 6f 6e 74 65 78 74 3b 0d text = context;.
3df0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 65 74 . Set
3e00: 52 65 74 75 72 6e 56 61 6c 75 65 28 63 6f 6e 74 ReturnValue(cont
3e10: 65 78 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ext,..
3e20: 20 20 20 20 20 20 49 6e 76 6f 6b 65 28 43 6f 6e Invoke(Con
3e30: 76 65 72 74 50 61 72 61 6d 73 28 6e 41 72 67 73 vertParams(nArgs
3e40: 2c 20 61 72 67 73 70 74 72 29 29 29 3b 20 2f 2a , argsptr))); /*
3e50: 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 throw */..
3e60: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 63 61 }.. ca
3e70: 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e 20 65 tch (Exception e
3e80: 29 20 2f 2a 20 4e 4f 54 45 3a 20 4d 75 73 74 20 ) /* NOTE: Must
3e90: 63 61 74 63 68 20 41 4c 4c 2e 20 2a 2f 0d 0a 20 catch ALL. */..
3ea0: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
3eb0: 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 try..
3ec0: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
3ed0: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 5f if ((_
3ee0: 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 43 6f flags & SQLiteCo
3ef0: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f nnectionFlags.Lo
3f00: 67 43 61 6c 6c 62 61 63 6b 45 78 63 65 70 74 69 gCallbackExcepti
3f10: 6f 6e 29 20 3d 3d 0d 0a 20 20 20 20 20 20 20 20 on) ==..
3f20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3f30: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
3f40: 46 6c 61 67 73 2e 4c 6f 67 43 61 6c 6c 62 61 63 Flags.LogCallbac
3f50: 6b 45 78 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 kException)..
3f60: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
3f70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3f80: 20 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f SQLiteLog.Lo
3f90: 67 4d 65 73 73 61 67 65 28 53 51 4c 69 74 65 42 gMessage(SQLiteB
3fa0: 61 73 65 2e 43 4f 52 5f 45 5f 45 58 43 45 50 54 ase.COR_E_EXCEPT
3fb0: 49 4f 4e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ION,..
3fc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 55 6e Un
3fd0: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
3fe0: 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 43 s.StringFormat(C
3ff0: 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 ultureInfo.Curre
4000: 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 ntCulture,..
4010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4020: 20 20 20 20 22 43 61 75 67 68 74 20 65 78 63 65 "Caught exce
4030: 70 74 69 6f 6e 20 69 6e 20 5c 22 49 6e 76 6f 6b ption in \"Invok
4040: 65 5c 22 20 6d 65 74 68 6f 64 3a 20 7b 30 7d 22 e\" method: {0}"
4050: 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ,..
4060: 20 20 20 20 20 20 20 20 20 20 20 65 29 29 3b 20 e));
4070: 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 /* throw */..
4080: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
4090: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
40a0: 20 20 20 20 20 20 20 20 20 20 20 63 61 74 63 68 catch
40b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d .. {.
40c0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
40d0: 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 2e 0d // do nothing..
40e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a . }..
40f0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d }.. }
4100: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
4110: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 49 mary>.. /// I
4120: 6e 74 65 72 6e 61 6c 20 63 6f 6c 6c 61 74 69 6f nternal collatio
4130: 6e 20 73 65 71 75 65 6e 63 65 20 66 75 6e 63 74 n sequence funct
4140: 69 6f 6e 2c 20 77 68 69 63 68 20 77 72 61 70 73 ion, which wraps
4150: 20 75 70 20 74 68 65 20 72 61 77 20 73 74 72 69 up the raw stri
4160: 6e 67 20 70 6f 69 6e 74 65 72 73 20 61 6e 64 20 ng pointers and
4170: 65 78 65 63 75 74 65 73 20 74 68 65 20 43 6f 6d executes the Com
4180: 70 61 72 65 28 29 20 76 69 72 74 75 61 6c 20 66 pare() virtual f
4190: 75 6e 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f unction... //
41a0: 2f 20 57 41 52 4e 49 4e 47 3a 20 4d 75 73 74 20 / WARNING: Must
41b0: 6e 6f 74 20 74 68 72 6f 77 20 65 78 63 65 70 74 not throw except
41c0: 69 6f 6e 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c ions... /// <
41d0: 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f /summary>.. /
41e0: 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
41f0: 70 74 72 22 3e 4e 6f 74 20 75 73 65 64 3c 2f 70 ptr">Not used</p
4200: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
4210: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 6c 65 6e 31 param name="len1
4220: 22 3e 4c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 ">Length of the
4230: 73 74 72 69 6e 67 20 70 76 31 3c 2f 70 61 72 61 string pv1</para
4240: 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 m>.. /// <par
4250: 61 6d 20 6e 61 6d 65 3d 22 70 74 72 31 22 3e 50 am name="ptr1">P
4260: 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 66 69 ointer to the fi
4270: 72 73 74 20 73 74 72 69 6e 67 20 74 6f 20 63 6f rst string to co
4280: 6d 70 61 72 65 3c 2f 70 61 72 61 6d 3e 0d 0a 20 mpare</param>..
4290: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
42a0: 6d 65 3d 22 6c 65 6e 32 22 3e 4c 65 6e 67 74 68 me="len2">Length
42b0: 20 6f 66 20 74 68 65 20 73 74 72 69 6e 67 20 70 of the string p
42c0: 76 32 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 v2</param>..
42d0: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
42e0: 22 70 74 72 32 22 3e 50 6f 69 6e 74 65 72 20 74 "ptr2">Pointer t
42f0: 6f 20 74 68 65 20 73 65 63 6f 6e 64 20 73 74 72 o the second str
4300: 69 6e 67 20 74 6f 20 63 6f 6d 70 61 72 65 3c 2f ing to compare</
4310: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
4320: 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 <returns>Returns
4330: 20 2d 31 20 69 66 20 74 68 65 20 66 69 72 73 74 -1 if the first
4340: 20 73 74 72 69 6e 67 20 69 73 20 6c 65 73 73 20 string is less
4350: 74 68 61 6e 20 74 68 65 20 73 65 63 6f 6e 64 2e than the second.
4360: 20 20 30 20 69 66 20 74 68 65 79 20 61 72 65 20 0 if they are
4370: 65 71 75 61 6c 2c 20 6f 72 20 31 20 69 66 20 74 equal, or 1 if t
4380: 68 65 20 66 69 72 73 74 20 73 74 72 69 6e 67 20 he first string
4390: 69 73 20 67 72 65 61 74 65 72 0d 0a 20 20 20 20 is greater..
43a0: 2f 2f 2f 20 74 68 61 6e 20 74 68 65 20 73 65 63 /// than the sec
43b0: 6f 6e 64 2e 20 20 52 65 74 75 72 6e 73 20 30 20 ond. Returns 0
43c0: 69 66 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 if an exception
43d0: 69 73 20 63 61 75 67 68 74 2e 3c 2f 72 65 74 75 is caught.</retu
43e0: 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e rns>.. intern
43f0: 61 6c 20 69 6e 74 20 43 6f 6d 70 61 72 65 43 61 al int CompareCa
4400: 6c 6c 62 61 63 6b 28 49 6e 74 50 74 72 20 70 74 llback(IntPtr pt
4410: 72 2c 20 69 6e 74 20 6c 65 6e 31 2c 20 49 6e 74 r, int len1, Int
4420: 50 74 72 20 70 74 72 31 2c 20 69 6e 74 20 6c 65 Ptr ptr1, int le
4430: 6e 32 2c 20 49 6e 74 50 74 72 20 70 74 72 32 29 n2, IntPtr ptr2)
4440: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
4450: 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d try.. {.
4460: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
4470: 75 72 6e 20 43 6f 6d 70 61 72 65 28 53 51 4c 69 urn Compare(SQLi
4480: 74 65 43 6f 6e 76 65 72 74 2e 55 54 46 38 54 6f teConvert.UTF8To
4490: 53 74 72 69 6e 67 28 70 74 72 31 2c 20 6c 65 6e String(ptr1, len
44a0: 31 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 1),..
44b0: 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 76 65 SQLiteConve
44c0: 72 74 2e 55 54 46 38 54 6f 53 74 72 69 6e 67 28 rt.UTF8ToString(
44d0: 70 74 72 32 2c 20 6c 65 6e 32 29 29 3b 20 2f 2a ptr2, len2)); /*
44e0: 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 throw */..
44f0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 63 61 }.. ca
4500: 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e 20 65 tch (Exception e
4510: 29 20 2f 2a 20 4e 4f 54 45 3a 20 4d 75 73 74 20 ) /* NOTE: Must
4520: 63 61 74 63 68 20 41 4c 4c 2e 20 2a 2f 0d 0a 20 catch ALL. */..
4530: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
4540: 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 try..
4550: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
4560: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 5f if ((_
4570: 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 43 6f flags & SQLiteCo
4580: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f nnectionFlags.Lo
4590: 67 43 61 6c 6c 62 61 63 6b 45 78 63 65 70 74 69 gCallbackExcepti
45a0: 6f 6e 29 20 3d 3d 0d 0a 20 20 20 20 20 20 20 20 on) ==..
45b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
45c0: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
45d0: 46 6c 61 67 73 2e 4c 6f 67 43 61 6c 6c 62 61 63 Flags.LogCallbac
45e0: 6b 45 78 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 kException)..
45f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
4600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4610: 20 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f SQLiteLog.Lo
4620: 67 4d 65 73 73 61 67 65 28 53 51 4c 69 74 65 42 gMessage(SQLiteB
4630: 61 73 65 2e 43 4f 52 5f 45 5f 45 58 43 45 50 54 ase.COR_E_EXCEPT
4640: 49 4f 4e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ION,..
4650: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 55 6e Un
4660: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
4670: 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 43 s.StringFormat(C
4680: 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 ultureInfo.Curre
4690: 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 ntCulture,..
46a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
46b0: 20 20 20 20 22 43 61 75 67 68 74 20 65 78 63 65 "Caught exce
46c0: 70 74 69 6f 6e 20 69 6e 20 5c 22 43 6f 6d 70 61 ption in \"Compa
46d0: 72 65 5c 22 20 28 55 54 46 38 29 20 6d 65 74 68 re\" (UTF8) meth
46e0: 6f 64 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 od: {0}",..
46f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4700: 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 72 6f 77 e)); /* throw
4710: 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 */..
4720: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
4730: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 }..
4740: 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 20 catch..
4750: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
4760: 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e // do n
4770: 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 othing...
4780: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
4790: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d }.... //.
47a0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 . // NOTE
47b0: 3a 20 54 68 69 73 20 6d 75 73 74 20 62 65 20 64 : This must be d
47c0: 6f 6e 65 20 74 6f 20 70 72 65 76 65 6e 74 20 74 one to prevent t
47d0: 68 65 20 63 6f 72 65 20 53 51 4c 69 74 65 20 6c he core SQLite l
47e0: 69 62 72 61 72 79 20 66 72 6f 6d 0d 0a 20 20 20 ibrary from..
47f0: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 75 73 // us
4800: 69 6e 67 20 6f 75 72 20 28 69 6e 76 61 6c 69 64 ing our (invalid
4810: 29 20 72 65 73 75 6c 74 2e 0d 0a 20 20 20 20 20 ) result...
4820: 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 69 //.. i
4830: 66 20 28 28 5f 62 61 73 65 20 21 3d 20 6e 75 6c f ((_base != nul
4840: 6c 29 20 26 26 20 5f 62 61 73 65 2e 49 73 4f 70 l) && _base.IsOp
4850: 65 6e 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 en())..
4860: 20 20 20 5f 62 61 73 65 2e 43 61 6e 63 65 6c 28 _base.Cancel(
4870: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 );.... re
4880: 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 7d 0d 0a turn 0;.. }..
4890: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
48a0: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 49 6e 74 ry>.. /// Int
48b0: 65 72 6e 61 6c 20 63 6f 6c 6c 61 74 69 6f 6e 20 ernal collation
48c0: 73 65 71 75 65 6e 63 65 20 66 75 6e 63 74 69 6f sequence functio
48d0: 6e 2c 20 77 68 69 63 68 20 77 72 61 70 73 20 75 n, which wraps u
48e0: 70 20 74 68 65 20 72 61 77 20 73 74 72 69 6e 67 p the raw string
48f0: 20 70 6f 69 6e 74 65 72 73 20 61 6e 64 20 65 78 pointers and ex
4900: 65 63 75 74 65 73 20 74 68 65 20 43 6f 6d 70 61 ecutes the Compa
4910: 72 65 28 29 20 76 69 72 74 75 61 6c 20 66 75 6e re() virtual fun
4920: 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ction... ///
4930: 57 41 52 4e 49 4e 47 3a 20 4d 75 73 74 20 6e 6f WARNING: Must no
4940: 74 20 74 68 72 6f 77 20 65 78 63 65 70 74 69 6f t throw exceptio
4950: 6e 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ns... /// </s
4960: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
4970: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 74 <param name="pt
4980: 72 22 3e 4e 6f 74 20 75 73 65 64 3c 2f 70 61 72 r">Not used</par
4990: 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 am>.. /// <pa
49a0: 72 61 6d 20 6e 61 6d 65 3d 22 6c 65 6e 31 22 3e ram name="len1">
49b0: 4c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 73 74 Length of the st
49c0: 72 69 6e 67 20 70 76 31 3c 2f 70 61 72 61 6d 3e ring pv1</param>
49d0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
49e0: 20 6e 61 6d 65 3d 22 70 74 72 31 22 3e 50 6f 69 name="ptr1">Poi
49f0: 6e 74 65 72 20 74 6f 20 74 68 65 20 66 69 72 73 nter to the firs
4a00: 74 20 73 74 72 69 6e 67 20 74 6f 20 63 6f 6d 70 t string to comp
4a10: 61 72 65 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 are</param>..
4a20: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
4a30: 3d 22 6c 65 6e 32 22 3e 4c 65 6e 67 74 68 20 6f ="len2">Length o
4a40: 66 20 74 68 65 20 73 74 72 69 6e 67 20 70 76 32 f the string pv2
4a50: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
4a60: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 / <param name="p
4a70: 74 72 32 22 3e 50 6f 69 6e 74 65 72 20 74 6f 20 tr2">Pointer to
4a80: 74 68 65 20 73 65 63 6f 6e 64 20 73 74 72 69 6e the second strin
4a90: 67 20 74 6f 20 63 6f 6d 70 61 72 65 3c 2f 70 61 g to compare</pa
4aa0: 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ram>.. /// <r
4ab0: 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 20 2d eturns>Returns -
4ac0: 31 20 69 66 20 74 68 65 20 66 69 72 73 74 20 73 1 if the first s
4ad0: 74 72 69 6e 67 20 69 73 20 6c 65 73 73 20 74 68 tring is less th
4ae0: 61 6e 20 74 68 65 20 73 65 63 6f 6e 64 2e 20 20 an the second.
4af0: 30 20 69 66 20 74 68 65 79 20 61 72 65 20 65 71 0 if they are eq
4b00: 75 61 6c 2c 20 6f 72 20 31 20 69 66 20 74 68 65 ual, or 1 if the
4b10: 20 66 69 72 73 74 20 73 74 72 69 6e 67 20 69 73 first string is
4b20: 20 67 72 65 61 74 65 72 0d 0a 20 20 20 20 2f 2f greater.. //
4b30: 2f 20 74 68 61 6e 20 74 68 65 20 73 65 63 6f 6e / than the secon
4b40: 64 2e 20 20 52 65 74 75 72 6e 73 20 30 20 69 66 d. Returns 0 if
4b50: 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 69 73 an exception is
4b60: 20 63 61 75 67 68 74 2e 3c 2f 72 65 74 75 72 6e caught.</return
4b70: 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c s>.. internal
4b80: 20 69 6e 74 20 43 6f 6d 70 61 72 65 43 61 6c 6c int CompareCall
4b90: 62 61 63 6b 31 36 28 49 6e 74 50 74 72 20 70 74 back16(IntPtr pt
4ba0: 72 2c 20 69 6e 74 20 6c 65 6e 31 2c 20 49 6e 74 r, int len1, Int
4bb0: 50 74 72 20 70 74 72 31 2c 20 69 6e 74 20 6c 65 Ptr ptr1, int le
4bc0: 6e 32 2c 20 49 6e 74 50 74 72 20 70 74 72 32 29 n2, IntPtr ptr2)
4bd0: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
4be0: 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d try.. {.
4bf0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
4c00: 75 72 6e 20 43 6f 6d 70 61 72 65 28 53 51 4c 69 urn Compare(SQLi
4c10: 74 65 33 5f 55 54 46 31 36 2e 55 54 46 31 36 54 te3_UTF16.UTF16T
4c20: 6f 53 74 72 69 6e 67 28 70 74 72 31 2c 20 6c 65 oString(ptr1, le
4c30: 6e 31 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 n1),..
4c40: 20 20 20 20 20 20 53 51 4c 69 74 65 33 5f 55 54 SQLite3_UT
4c50: 46 31 36 2e 55 54 46 31 36 54 6f 53 74 72 69 6e F16.UTF16ToStrin
4c60: 67 28 70 74 72 32 2c 20 6c 65 6e 32 29 29 3b 20 g(ptr2, len2));
4c70: 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 /* throw */..
4c80: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
4c90: 63 61 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e catch (Exception
4ca0: 20 65 29 20 2f 2a 20 4e 4f 54 45 3a 20 4d 75 73 e) /* NOTE: Mus
4cb0: 74 20 63 61 74 63 68 20 41 4c 4c 2e 20 2a 2f 0d t catch ALL. */.
4cc0: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
4cd0: 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 try..
4ce0: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
4cf0: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 if (
4d00: 28 5f 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 (_flags & SQLite
4d10: 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e ConnectionFlags.
4d20: 4c 6f 67 43 61 6c 6c 62 61 63 6b 45 78 63 65 70 LogCallbackExcep
4d30: 74 69 6f 6e 29 20 3d 3d 0d 0a 20 20 20 20 20 20 tion) ==..
4d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4d50: 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 SQLiteConnecti
4d60: 6f 6e 46 6c 61 67 73 2e 4c 6f 67 43 61 6c 6c 62 onFlags.LogCallb
4d70: 61 63 6b 45 78 63 65 70 74 69 6f 6e 29 0d 0a 20 ackException)..
4d80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b {
4d90: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
4da0: 20 20 20 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e SQLiteLog.
4db0: 4c 6f 67 4d 65 73 73 61 67 65 28 53 51 4c 69 74 LogMessage(SQLit
4dc0: 65 42 61 73 65 2e 43 4f 52 5f 45 5f 45 58 43 45 eBase.COR_E_EXCE
4dd0: 50 54 49 4f 4e 2c 0d 0a 20 20 20 20 20 20 20 20 PTION,..
4de0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4df0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
4e00: 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 ods.StringFormat
4e10: 28 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 (CultureInfo.Cur
4e20: 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 rentCulture,..
4e30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4e40: 20 20 20 20 20 20 22 43 61 75 67 68 74 20 65 78 "Caught ex
4e50: 63 65 70 74 69 6f 6e 20 69 6e 20 5c 22 43 6f 6d ception in \"Com
4e60: 70 61 72 65 5c 22 20 28 55 54 46 31 36 29 20 6d pare\" (UTF16) m
4e70: 65 74 68 6f 64 3a 20 7b 30 7d 22 2c 0d 0a 20 20 ethod: {0}",..
4e80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4e90: 20 20 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 e)); /* th
4ea0: 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 row */..
4eb0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
4ec0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
4ed0: 20 20 20 20 20 20 63 61 74 63 68 0d 0a 20 20 20 catch..
4ee0: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
4ef0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 // d
4f00: 6f 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 o nothing...
4f10: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
4f20: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
4f30: 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 4e //.. // N
4f40: 4f 54 45 3a 20 54 68 69 73 20 6d 75 73 74 20 62 OTE: This must b
4f50: 65 20 64 6f 6e 65 20 74 6f 20 70 72 65 76 65 6e e done to preven
4f60: 74 20 74 68 65 20 63 6f 72 65 20 53 51 4c 69 74 t the core SQLit
4f70: 65 20 6c 69 62 72 61 72 79 20 66 72 6f 6d 0d 0a e library from..
4f80: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
4f90: 20 75 73 69 6e 67 20 6f 75 72 20 28 69 6e 76 61 using our (inva
4fa0: 6c 69 64 29 20 72 65 73 75 6c 74 2e 0d 0a 20 20 lid) result...
4fb0: 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 //..
4fc0: 20 20 69 66 20 28 28 5f 62 61 73 65 20 21 3d 20 if ((_base !=
4fd0: 6e 75 6c 6c 29 20 26 26 20 5f 62 61 73 65 2e 49 null) && _base.I
4fe0: 73 4f 70 65 6e 28 29 29 0d 0a 20 20 20 20 20 20 sOpen())..
4ff0: 20 20 20 20 20 20 5f 62 61 73 65 2e 43 61 6e 63 _base.Canc
5000: 65 6c 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 el();....
5010: 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 return 0;..
5020: 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 }.... /// <su
5030: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
5040: 54 68 65 20 69 6e 74 65 72 6e 61 6c 20 61 67 67 The internal agg
5050: 72 65 67 61 74 65 20 53 74 65 70 20 66 75 6e 63 regate Step func
5060: 74 69 6f 6e 20 63 61 6c 6c 62 61 63 6b 2c 20 77 tion callback, w
5070: 68 69 63 68 20 77 72 61 70 73 20 74 68 65 20 72 hich wraps the r
5080: 61 77 20 63 6f 6e 74 65 78 74 20 70 6f 69 6e 74 aw context point
5090: 65 72 20 61 6e 64 20 63 61 6c 6c 73 20 74 68 65 er and calls the
50a0: 20 76 69 72 74 75 61 6c 20 53 74 65 70 28 29 20 virtual Step()
50b0: 6d 65 74 68 6f 64 2e 0d 0a 20 20 20 20 2f 2f 2f method... ///
50c0: 20 57 41 52 4e 49 4e 47 3a 20 4d 75 73 74 20 6e WARNING: Must n
50d0: 6f 74 20 74 68 72 6f 77 20 65 78 63 65 70 74 69 ot throw excepti
50e0: 6f 6e 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ons... /// </
50f0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
5100: 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 / <remarks>..
5110: 20 2f 2f 2f 20 54 68 69 73 20 66 75 6e 63 74 69 /// This functi
5120: 6f 6e 20 74 61 6b 65 73 20 63 61 72 65 20 6f 66 on takes care of
5130: 20 64 6f 69 6e 67 20 74 68 65 20 6c 6f 6f 6b 75 doing the looku
5140: 70 73 20 61 6e 64 20 67 65 74 74 69 6e 67 20 74 ps and getting t
5150: 68 65 20 69 6d 70 6f 72 74 61 6e 74 20 69 6e 66 he important inf
5160: 6f 72 6d 61 74 69 6f 6e 20 70 75 74 20 74 6f 67 ormation put tog
5170: 65 74 68 65 72 20 74 6f 20 63 61 6c 6c 20 74 68 ether to call th
5180: 65 20 53 74 65 70 28 29 20 66 75 6e 63 74 69 6f e Step() functio
5190: 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 61 74 n... /// That
51a0: 20 69 6e 63 6c 75 64 65 73 20 70 75 6c 6c 69 6e includes pullin
51b0: 67 20 6f 75 74 20 74 68 65 20 75 73 65 72 27 73 g out the user's
51c0: 20 63 6f 6e 74 65 78 74 44 61 74 61 20 61 6e 64 contextData and
51d0: 20 75 70 64 61 74 69 6e 67 20 69 74 20 61 66 74 updating it aft
51e0: 65 72 20 74 68 65 20 63 61 6c 6c 20 69 73 20 6d er the call is m
51f0: 61 64 65 2e 20 20 57 65 20 75 73 65 20 61 20 73 ade. We use a s
5200: 6f 72 74 65 64 20 6c 69 73 74 20 66 6f 72 20 74 orted list for t
5210: 68 69 73 20 73 6f 0d 0a 20 20 20 20 2f 2f 2f 20 his so.. ///
5220: 62 69 6e 61 72 79 20 73 65 61 72 63 68 65 73 20 binary searches
5230: 63 61 6e 20 62 65 20 64 6f 6e 65 20 74 6f 20 66 can be done to f
5240: 69 6e 64 20 74 68 65 20 64 61 74 61 2e 0d 0a 20 ind the data...
5250: 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 /// </remarks
5260: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
5270: 6d 20 6e 61 6d 65 3d 22 63 6f 6e 74 65 78 74 22 m name="context"
5280: 3e 41 20 72 61 77 20 63 6f 6e 74 65 78 74 20 70 >A raw context p
5290: 6f 69 6e 74 65 72 3c 2f 70 61 72 61 6d 3e 0d 0a ointer</param>..
52a0: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
52b0: 61 6d 65 3d 22 6e 41 72 67 73 22 3e 4e 75 6d 62 ame="nArgs">Numb
52c0: 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74 73 20 er of arguments
52d0: 70 61 73 73 65 64 20 69 6e 3c 2f 70 61 72 61 6d passed in</param
52e0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
52f0: 6d 20 6e 61 6d 65 3d 22 61 72 67 73 70 74 72 22 m name="argsptr"
5300: 3e 41 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 >A pointer to th
5310: 65 20 61 72 72 61 79 20 6f 66 20 61 72 67 75 6d e array of argum
5320: 65 6e 74 73 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 ents</param>..
5330: 20 20 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 internal void
5340: 53 74 65 70 43 61 6c 6c 62 61 63 6b 28 49 6e 74 StepCallback(Int
5350: 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 69 6e 74 Ptr context, int
5360: 20 6e 41 72 67 73 2c 20 49 6e 74 50 74 72 20 61 nArgs, IntPtr a
5370: 72 67 73 70 74 72 29 0d 0a 20 20 20 20 7b 0d 0a rgsptr).. {..
5380: 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 try..
5390: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
53a0: 20 20 20 20 41 67 67 72 65 67 61 74 65 44 61 74 AggregateDat
53b0: 61 20 64 61 74 61 20 3d 20 6e 75 6c 6c 3b 0d 0a a data = null;..
53c0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
53d0: 20 28 5f 62 61 73 65 20 21 3d 20 6e 75 6c 6c 29 (_base != null)
53e0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d .. {.
53f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
5400: 20 49 6e 74 50 74 72 20 6e 41 75 78 20 3d 20 5f IntPtr nAux = _
5410: 62 61 73 65 2e 41 67 67 72 65 67 61 74 65 43 6f base.AggregateCo
5420: 6e 74 65 78 74 28 63 6f 6e 74 65 78 74 29 3b 0d ntext(context);.
5430: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
5440: 20 20 20 69 66 20 28 28 5f 63 6f 6e 74 65 78 74 if ((_context
5450: 44 61 74 61 4c 69 73 74 20 21 3d 20 6e 75 6c 6c DataList != null
5460: 29 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 ) &&..
5470: 20 20 20 20 20 20 20 20 20 20 21 5f 63 6f 6e 74 !_cont
5480: 65 78 74 44 61 74 61 4c 69 73 74 2e 54 72 79 47 extDataList.TryG
5490: 65 74 56 61 6c 75 65 28 6e 41 75 78 2c 20 6f 75 etValue(nAux, ou
54a0: 74 20 64 61 74 61 29 29 0d 0a 20 20 20 20 20 20 t data))..
54b0: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
54c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
54d0: 20 64 61 74 61 20 3d 20 6e 65 77 20 41 67 67 72 data = new Aggr
54e0: 65 67 61 74 65 44 61 74 61 28 29 3b 0d 0a 20 20 egateData();..
54f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5500: 20 20 5f 63 6f 6e 74 65 78 74 44 61 74 61 4c 69 _contextDataLi
5510: 73 74 5b 6e 41 75 78 5d 20 3d 20 64 61 74 61 3b st[nAux] = data;
5520: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
5530: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }..
5540: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 }....
5550: 20 20 69 66 20 28 64 61 74 61 20 3d 3d 20 6e 75 if (data == nu
5560: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
5570: 20 20 20 20 20 64 61 74 61 20 3d 20 6e 65 77 20 data = new
5580: 41 67 67 72 65 67 61 74 65 44 61 74 61 28 29 3b AggregateData();
5590: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
55a0: 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 try..
55b0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
55c0: 20 20 20 20 5f 63 6f 6e 74 65 78 74 20 3d 20 63 _context = c
55d0: 6f 6e 74 65 78 74 3b 0d 0a 20 20 20 20 20 20 20 ontext;..
55e0: 20 20 20 20 20 20 20 20 20 53 74 65 70 28 43 6f Step(Co
55f0: 6e 76 65 72 74 50 61 72 61 6d 73 28 6e 41 72 67 nvertParams(nArg
5600: 73 2c 20 61 72 67 73 70 74 72 29 2c 0d 0a 20 20 s, argsptr),..
5610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5620: 20 20 64 61 74 61 2e 5f 63 6f 75 6e 74 2c 20 72 data._count, r
5630: 65 66 20 64 61 74 61 2e 5f 64 61 74 61 29 3b 20 ef data._data);
5640: 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 /* throw */..
5650: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
5660: 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d finally.
5670: 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a . {..
5680: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5690: 64 61 74 61 2e 5f 63 6f 75 6e 74 2b 2b 3b 0d 0a data._count++;..
56a0: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
56b0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
56c0: 20 20 63 61 74 63 68 20 28 45 78 63 65 70 74 69 catch (Excepti
56d0: 6f 6e 20 65 29 20 2f 2a 20 4e 4f 54 45 3a 20 4d on e) /* NOTE: M
56e0: 75 73 74 20 63 61 74 63 68 20 41 4c 4c 2e 20 2a ust catch ALL. *
56f0: 2f 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 /.. {..
5700: 20 20 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 try..
5710: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
5720: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
5730: 20 28 28 5f 66 6c 61 67 73 20 26 20 53 51 4c 69 ((_flags & SQLi
5740: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
5750: 73 2e 4c 6f 67 43 61 6c 6c 62 61 63 6b 45 78 63 s.LogCallbackExc
5760: 65 70 74 69 6f 6e 29 20 3d 3d 0d 0a 20 20 20 20 eption) ==..
5770: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5780: 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 SQLiteConnec
5790: 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 43 61 6c tionFlags.LogCal
57a0: 6c 62 61 63 6b 45 78 63 65 70 74 69 6f 6e 29 0d lbackException).
57b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
57c0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
57d0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 4c 6f SQLiteLo
57e0: 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 53 51 4c g.LogMessage(SQL
57f0: 69 74 65 42 61 73 65 2e 43 4f 52 5f 45 5f 45 58 iteBase.COR_E_EX
5800: 43 45 50 54 49 4f 4e 2c 0d 0a 20 20 20 20 20 20 CEPTION,..
5810: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5820: 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
5830: 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
5840: 61 74 28 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 at(CultureInfo.C
5850: 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a urrentCulture,..
5860: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5870: 20 20 20 20 20 20 20 20 22 43 61 75 67 68 74 20 "Caught
5880: 65 78 63 65 70 74 69 6f 6e 20 69 6e 20 5c 22 53 exception in \"S
5890: 74 65 70 5c 22 20 6d 65 74 68 6f 64 3a 20 7b 31 tep\" method: {1
58a0: 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }",..
58b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 65 29 29 e))
58c0: 3b 20 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 ; /* throw */..
58d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d }
58e0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d .. }.
58f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 74 . cat
5900: 63 68 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ch..
5910: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
5920: 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 // do nothing
5930: 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ... }
5940: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
5950: 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 }.... /// <s
5960: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
5970: 20 41 6e 20 69 6e 74 65 72 6e 61 6c 20 61 67 67 An internal agg
5980: 72 65 67 61 74 65 20 46 69 6e 61 6c 20 66 75 6e regate Final fun
5990: 63 74 69 6f 6e 20 63 61 6c 6c 62 61 63 6b 2c 20 ction callback,
59a0: 77 68 69 63 68 20 77 72 61 70 73 20 74 68 65 20 which wraps the
59b0: 63 6f 6e 74 65 78 74 20 70 6f 69 6e 74 65 72 20 context pointer
59c0: 61 6e 64 20 63 61 6c 6c 73 20 74 68 65 20 76 69 and calls the vi
59d0: 72 74 75 61 6c 20 46 69 6e 61 6c 28 29 20 6d 65 rtual Final() me
59e0: 74 68 6f 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 57 thod... /// W
59f0: 41 52 4e 49 4e 47 3a 20 4d 75 73 74 20 6e 6f 74 ARNING: Must not
5a00: 20 74 68 72 6f 77 20 65 78 63 65 70 74 69 6f 6e throw exception
5a10: 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 s... /// </su
5a20: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
5a30: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 63 6f 6e <param name="con
5a40: 74 65 78 74 22 3e 41 20 72 61 77 20 63 6f 6e 74 text">A raw cont
5a50: 65 78 74 20 70 6f 69 6e 74 65 72 3c 2f 70 61 72 ext pointer</par
5a60: 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 am>.. interna
5a70: 6c 20 76 6f 69 64 20 46 69 6e 61 6c 43 61 6c 6c l void FinalCall
5a80: 62 61 63 6b 28 49 6e 74 50 74 72 20 63 6f 6e 74 back(IntPtr cont
5a90: 65 78 74 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ext).. {..
5aa0: 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 try..
5ab0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
5ac0: 20 6f 62 6a 65 63 74 20 6f 62 6a 20 3d 20 6e 75 object obj = nu
5ad0: 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ll;....
5ae0: 20 20 20 69 66 20 28 5f 62 61 73 65 20 21 3d 20 if (_base !=
5af0: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
5b00: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
5b10: 20 20 20 20 20 20 49 6e 74 50 74 72 20 6e 20 3d IntPtr n =
5b20: 20 5f 62 61 73 65 2e 41 67 67 72 65 67 61 74 65 _base.Aggregate
5b30: 43 6f 6e 74 65 78 74 28 63 6f 6e 74 65 78 74 29 Context(context)
5b40: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
5b50: 20 20 20 41 67 67 72 65 67 61 74 65 44 61 74 61 AggregateData
5b60: 20 61 67 67 44 61 74 61 3b 0d 0a 0d 0a 20 20 20 aggData;....
5b70: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
5b80: 28 28 5f 63 6f 6e 74 65 78 74 44 61 74 61 4c 69 ((_contextDataLi
5b90: 73 74 20 21 3d 20 6e 75 6c 6c 29 20 26 26 0d 0a st != null) &&..
5ba0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5bb0: 20 20 20 20 5f 63 6f 6e 74 65 78 74 44 61 74 61 _contextData
5bc0: 4c 69 73 74 2e 54 72 79 47 65 74 56 61 6c 75 65 List.TryGetValue
5bd0: 28 6e 2c 20 6f 75 74 20 61 67 67 44 61 74 61 29 (n, out aggData)
5be0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
5bf0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
5c00: 20 20 20 20 20 20 20 20 20 20 6f 62 6a 20 3d 20 obj =
5c10: 61 67 67 44 61 74 61 2e 5f 64 61 74 61 3b 0d 0a aggData._data;..
5c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5c30: 20 20 20 20 5f 63 6f 6e 74 65 78 74 44 61 74 61 _contextData
5c40: 4c 69 73 74 2e 52 65 6d 6f 76 65 28 6e 29 3b 0d List.Remove(n);.
5c50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
5c60: 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
5c70: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }....
5c80: 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 try..
5c90: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
5ca0: 20 20 20 20 20 5f 63 6f 6e 74 65 78 74 20 3d 20 _context =
5cb0: 63 6f 6e 74 65 78 74 3b 0d 0a 20 20 20 20 20 20 context;..
5cc0: 20 20 20 20 20 20 20 20 20 20 53 65 74 52 65 74 SetRet
5cd0: 75 72 6e 56 61 6c 75 65 28 63 6f 6e 74 65 78 74 urnValue(context
5ce0: 2c 20 46 69 6e 61 6c 28 6f 62 6a 29 29 3b 20 2f , Final(obj)); /
5cf0: 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 * throw */..
5d00: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
5d10: 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a finally..
5d20: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
5d30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 I
5d40: 44 69 73 70 6f 73 61 62 6c 65 20 64 69 73 70 20 Disposable disp
5d50: 3d 20 6f 62 6a 20 61 73 20 49 44 69 73 70 6f 73 = obj as IDispos
5d60: 61 62 6c 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 able;..
5d70: 20 20 20 20 20 20 20 69 66 20 28 64 69 73 70 20 if (disp
5d80: 21 3d 20 6e 75 6c 6c 29 20 64 69 73 70 2e 44 69 != null) disp.Di
5d90: 73 70 6f 73 65 28 29 3b 20 2f 2a 20 74 68 72 6f spose(); /* thro
5da0: 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 w */..
5db0: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a }.. }..
5dc0: 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
5dd0: 78 63 65 70 74 69 6f 6e 20 65 29 20 2f 2a 20 4e xception e) /* N
5de0: 4f 54 45 3a 20 4d 75 73 74 20 63 61 74 63 68 20 OTE: Must catch
5df0: 41 4c 4c 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 20 ALL. */..
5e00: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
5e10: 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 try..
5e20: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
5e30: 20 20 20 20 69 66 20 28 28 5f 66 6c 61 67 73 20 if ((_flags
5e40: 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 & SQLiteConnecti
5e50: 6f 6e 46 6c 61 67 73 2e 4c 6f 67 43 61 6c 6c 62 onFlags.LogCallb
5e60: 61 63 6b 45 78 63 65 70 74 69 6f 6e 29 20 3d 3d ackException) ==
5e70: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
5e80: 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
5e90: 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e ConnectionFlags.
5ea0: 4c 6f 67 43 61 6c 6c 62 61 63 6b 45 78 63 65 70 LogCallbackExcep
5eb0: 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 tion)..
5ec0: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
5ed0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 SQ
5ee0: 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 LiteLog.LogMessa
5ef0: 67 65 28 53 51 4c 69 74 65 42 61 73 65 2e 43 4f ge(SQLiteBase.CO
5f00: 52 5f 45 5f 45 58 43 45 50 54 49 4f 4e 2c 0d 0a R_E_EXCEPTION,..
5f10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5f20: 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 UnsafeNa
5f30: 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 tiveMethods.Stri
5f40: 6e 67 46 6f 72 6d 61 74 28 43 75 6c 74 75 72 65 ngFormat(Culture
5f50: 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 Info.CurrentCult
5f60: 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ure,..
5f70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 43 "C
5f80: 61 75 67 68 74 20 65 78 63 65 70 74 69 6f 6e 20 aught exception
5f90: 69 6e 20 5c 22 46 69 6e 61 6c 5c 22 20 6d 65 74 in \"Final\" met
5fa0: 68 6f 64 3a 20 7b 31 7d 22 2c 0d 0a 20 20 20 20 hod: {1}",..
5fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5fc0: 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 72 6f e)); /* thro
5fd0: 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 w */..
5fe0: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
5ff0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
6000: 20 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 catch..
6010: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
6020: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 // do
6030: 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 nothing...
6040: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
6050: 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }.. }....
6060: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
6070: 20 20 20 20 2f 2f 2f 20 55 73 69 6e 67 20 72 65 /// Using re
6080: 66 6c 65 63 74 69 6f 6e 2c 20 65 6e 75 6d 65 72 flection, enumer
6090: 61 74 65 20 61 6c 6c 20 61 73 73 65 6d 62 6c 69 ate all assembli
60a0: 65 73 20 69 6e 20 74 68 65 20 63 75 72 72 65 6e es in the curren
60b0: 74 20 61 70 70 64 6f 6d 61 69 6e 20 6c 6f 6f 6b t appdomain look
60c0: 69 6e 67 20 66 6f 72 20 63 6c 61 73 73 65 73 20 ing for classes
60d0: 74 68 61 74 0d 0a 20 20 20 20 2f 2f 2f 20 68 61 that.. /// ha
60e0: 76 65 20 61 20 53 51 4c 69 74 65 46 75 6e 63 74 ve a SQLiteFunct
60f0: 69 6f 6e 41 74 74 72 69 62 75 74 65 20 61 74 74 ionAttribute att
6100: 72 69 62 75 74 65 2c 20 61 6e 64 20 72 65 67 69 ribute, and regi
6110: 73 74 65 72 69 6e 67 20 74 68 65 6d 20 61 63 63 stering them acc
6120: 6f 72 64 69 6e 67 6c 79 2e 0d 0a 20 20 20 20 2f ordingly... /
6130: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 23 // </summary>..#
6140: 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d if !PLATFORM_COM
6150: 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 PACTFRAMEWORK..
6160: 20 20 20 5b 53 65 63 75 72 69 74 79 2e 50 65 72 [Security.Per
6170: 6d 69 73 73 69 6f 6e 73 2e 46 69 6c 65 49 4f 50 missions.FileIOP
6180: 65 72 6d 69 73 73 69 6f 6e 28 53 65 63 75 72 69 ermission(Securi
6190: 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e 53 ty.Permissions.S
61a0: 65 63 75 72 69 74 79 41 63 74 69 6f 6e 2e 41 73 ecurityAction.As
61b0: 73 65 72 74 2c 20 41 6c 6c 46 69 6c 65 73 20 3d sert, AllFiles =
61c0: 20 53 65 63 75 72 69 74 79 2e 50 65 72 6d 69 73 Security.Permis
61d0: 73 69 6f 6e 73 2e 46 69 6c 65 49 4f 50 65 72 6d sions.FileIOPerm
61e0: 69 73 73 69 6f 6e 41 63 63 65 73 73 2e 50 61 74 issionAccess.Pat
61f0: 68 44 69 73 63 6f 76 65 72 79 29 5d 0d 0a 23 65 hDiscovery)]..#e
6200: 6e 64 69 66 0d 0a 20 20 20 20 73 74 61 74 69 63 ndif.. static
6210: 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 28 SQLiteFunction(
6220: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
6230: 5f 72 65 67 69 73 74 65 72 65 64 46 75 6e 63 74 _registeredFunct
6240: 69 6f 6e 73 20 3d 20 6e 65 77 20 44 69 63 74 69 ions = new Dicti
6250: 6f 6e 61 72 79 3c 53 51 4c 69 74 65 46 75 6e 63 onary<SQLiteFunc
6260: 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 6f tionAttribute, o
6270: 62 6a 65 63 74 3e 28 29 3b 0d 0a 20 20 20 20 20 bject>();..
6280: 20 74 72 79 0d 0a 20 20 20 20 20 20 7b 0d 0a 23 try.. {..#
6290: 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d if !PLATFORM_COM
62a0: 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 PACTFRAMEWORK..
62b0: 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 //..
62c0: 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 66 20 74 // NOTE: If t
62d0: 68 65 20 22 4e 6f 5f 53 51 4c 69 74 65 46 75 6e he "No_SQLiteFun
62e0: 63 74 69 6f 6e 73 22 20 65 6e 76 69 72 6f 6e 6d ctions" environm
62f0: 65 6e 74 20 76 61 72 69 61 62 6c 65 20 69 73 20 ent variable is
6300: 73 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 2f 2f set,.. //
6310: 20 20 20 20 20 20 20 73 6b 69 70 20 61 6c 6c 20 skip all
6320: 6f 75 72 20 73 70 65 63 69 61 6c 20 63 6f 64 65 our special code
6330: 20 61 6e 64 20 73 69 6d 70 6c 79 20 72 65 74 75 and simply retu
6340: 72 6e 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d rn... //.
6350: 0a 20 20 20 20 20 20 20 20 69 66 20 28 55 6e 73 . if (Uns
6360: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
6370: 2e 47 65 74 53 65 74 74 69 6e 67 56 61 6c 75 65 .GetSettingValue
6380: 28 22 4e 6f 5f 53 51 4c 69 74 65 46 75 6e 63 74 ("No_SQLiteFunct
6390: 69 6f 6e 73 22 2c 20 6e 75 6c 6c 29 20 21 3d 20 ions", null) !=
63a0: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
63b0: 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 return;....
63c0: 20 20 20 20 53 51 4c 69 74 65 46 75 6e 63 74 69 SQLiteFuncti
63d0: 6f 6e 41 74 74 72 69 62 75 74 65 20 61 74 3b 0d onAttribute at;.
63e0: 0a 20 20 20 20 20 20 20 20 53 79 73 74 65 6d 2e . System.
63f0: 52 65 66 6c 65 63 74 69 6f 6e 2e 41 73 73 65 6d Reflection.Assem
6400: 62 6c 79 5b 5d 20 61 72 41 73 73 65 6d 62 6c 69 bly[] arAssembli
6410: 65 73 20 3d 20 53 79 73 74 65 6d 2e 41 70 70 44 es = System.AppD
6420: 6f 6d 61 69 6e 2e 43 75 72 72 65 6e 74 44 6f 6d omain.CurrentDom
6430: 61 69 6e 2e 47 65 74 41 73 73 65 6d 62 6c 69 65 ain.GetAssemblie
6440: 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e s();.. in
6450: 74 20 77 20 3d 20 61 72 41 73 73 65 6d 62 6c 69 t w = arAssembli
6460: 65 73 2e 4c 65 6e 67 74 68 3b 0d 0a 20 20 20 20 es.Length;..
6470: 20 20 20 20 53 79 73 74 65 6d 2e 52 65 66 6c 65 System.Refle
6480: 63 74 69 6f 6e 2e 41 73 73 65 6d 62 6c 79 4e 61 ction.AssemblyNa
6490: 6d 65 20 73 71 6c 69 74 65 20 3d 20 53 79 73 74 me sqlite = Syst
64a0: 65 6d 2e 52 65 66 6c 65 63 74 69 6f 6e 2e 41 73 em.Reflection.As
64b0: 73 65 6d 62 6c 79 2e 47 65 74 45 78 65 63 75 74 sembly.GetExecut
64c0: 69 6e 67 41 73 73 65 6d 62 6c 79 28 29 2e 47 65 ingAssembly().Ge
64d0: 74 4e 61 6d 65 28 29 3b 0d 0a 0d 0a 20 20 20 20 tName();....
64e0: 20 20 20 20 66 6f 72 20 28 69 6e 74 20 6e 20 3d for (int n =
64f0: 20 30 3b 20 6e 20 3c 20 77 3b 20 6e 2b 2b 29 0d 0; n < w; n++).
6500: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
6510: 20 20 20 20 20 20 54 79 70 65 5b 5d 20 61 72 54 Type[] arT
6520: 79 70 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 ypes;..
6530: 20 62 6f 6f 6c 20 66 6f 75 6e 64 20 3d 20 66 61 bool found = fa
6540: 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 lse;..
6550: 53 79 73 74 65 6d 2e 52 65 66 6c 65 63 74 69 6f System.Reflectio
6560: 6e 2e 41 73 73 65 6d 62 6c 79 4e 61 6d 65 5b 5d n.AssemblyName[]
6570: 20 72 65 66 65 72 65 6e 63 65 73 3b 0d 0a 20 20 references;..
6580: 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 try..
6590: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
65a0: 20 20 20 20 20 20 2f 2f 20 49 6e 73 70 65 63 74 // Inspect
65b0: 20 6f 6e 6c 79 20 61 73 73 65 6d 62 6c 69 65 73 only assemblies
65c0: 20 74 68 61 74 20 72 65 66 65 72 65 6e 63 65 20 that reference
65d0: 53 51 4c 69 74 65 0d 0a 20 20 20 20 20 20 20 20 SQLite..
65e0: 20 20 20 20 72 65 66 65 72 65 6e 63 65 73 20 3d references =
65f0: 20 61 72 41 73 73 65 6d 62 6c 69 65 73 5b 6e 5d arAssemblies[n]
6600: 2e 47 65 74 52 65 66 65 72 65 6e 63 65 64 41 73 .GetReferencedAs
6610: 73 65 6d 62 6c 69 65 73 28 29 3b 0d 0a 20 20 20 semblies();..
6620: 20 20 20 20 20 20 20 20 20 69 6e 74 20 74 20 3d int t =
6630: 20 72 65 66 65 72 65 6e 63 65 73 2e 4c 65 6e 67 references.Leng
6640: 74 68 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 th;..
6650: 20 66 6f 72 20 28 69 6e 74 20 7a 20 3d 20 30 3b for (int z = 0;
6660: 20 7a 20 3c 20 74 3b 20 7a 2b 2b 29 0d 0a 20 20 z < t; z++)..
6670: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
6680: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 if (r
6690: 65 66 65 72 65 6e 63 65 73 5b 7a 5d 2e 4e 61 6d eferences[z].Nam
66a0: 65 20 3d 3d 20 73 71 6c 69 74 65 2e 4e 61 6d 65 e == sqlite.Name
66b0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
66c0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
66d0: 20 20 20 20 66 6f 75 6e 64 20 3d 20 74 72 75 65 found = true
66e0: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
66f0: 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 break;..
6700: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
6710: 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
6720: 20 20 20 20 20 20 20 20 20 69 66 20 28 66 6f 75 if (fou
6730: 6e 64 20 3d 3d 20 66 61 6c 73 65 29 0d 0a 20 20 nd == false)..
6740: 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 cont
6750: 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 inue;....
6760: 20 20 20 20 20 61 72 54 79 70 65 73 20 3d 20 61 arTypes = a
6770: 72 41 73 73 65 6d 62 6c 69 65 73 5b 6e 5d 2e 47 rAssemblies[n].G
6780: 65 74 54 79 70 65 73 28 29 3b 0d 0a 20 20 20 20 etTypes();..
6790: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
67a0: 20 20 20 63 61 74 63 68 20 28 52 65 66 6c 65 63 catch (Reflec
67b0: 74 69 6f 6e 2e 52 65 66 6c 65 63 74 69 6f 6e 54 tion.ReflectionT
67c0: 79 70 65 4c 6f 61 64 45 78 63 65 70 74 69 6f 6e ypeLoadException
67d0: 20 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 7b e).. {
67e0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 72 .. ar
67f0: 54 79 70 65 73 20 3d 20 65 2e 54 79 70 65 73 3b Types = e.Types;
6800: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d .. }...
6810: 0a 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 76 . int v
6820: 20 3d 20 61 72 54 79 70 65 73 2e 4c 65 6e 67 74 = arTypes.Lengt
6830: 68 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 66 6f h;.. fo
6840: 72 20 28 69 6e 74 20 78 20 3d 20 30 3b 20 78 20 r (int x = 0; x
6850: 3c 20 76 3b 20 78 2b 2b 29 0d 0a 20 20 20 20 20 < v; x++)..
6860: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
6870: 20 20 20 20 69 66 20 28 61 72 54 79 70 65 73 5b if (arTypes[
6880: 78 5d 20 3d 3d 20 6e 75 6c 6c 29 20 63 6f 6e 74 x] == null) cont
6890: 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 inue;....
68a0: 20 20 20 20 20 6f 62 6a 65 63 74 5b 5d 20 61 72 object[] ar
68b0: 41 74 74 20 3d 20 61 72 54 79 70 65 73 5b 78 5d Att = arTypes[x]
68c0: 2e 47 65 74 43 75 73 74 6f 6d 41 74 74 72 69 62 .GetCustomAttrib
68d0: 75 74 65 73 28 74 79 70 65 6f 66 28 53 51 4c 69 utes(typeof(SQLi
68e0: 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 teFunctionAttrib
68f0: 75 74 65 29 2c 20 66 61 6c 73 65 29 3b 0d 0a 20 ute), false);..
6900: 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 75 int u
6910: 20 3d 20 61 72 41 74 74 2e 4c 65 6e 67 74 68 3b = arAtt.Length;
6920: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f .. fo
6930: 72 20 28 69 6e 74 20 79 20 3d 20 30 3b 20 79 20 r (int y = 0; y
6940: 3c 20 75 3b 20 79 2b 2b 29 0d 0a 20 20 20 20 20 < u; y++)..
6950: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
6960: 20 20 20 20 20 20 20 20 61 74 20 3d 20 61 72 41 at = arA
6970: 74 74 5b 79 5d 20 61 73 20 53 51 4c 69 74 65 46 tt[y] as SQLiteF
6980: 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 unctionAttribute
6990: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
69a0: 20 69 66 20 28 61 74 20 21 3d 20 6e 75 6c 6c 29 if (at != null)
69b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
69c0: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
69d0: 20 20 20 61 74 2e 49 6e 73 74 61 6e 63 65 54 79 at.InstanceTy
69e0: 70 65 20 3d 20 61 72 54 79 70 65 73 5b 78 5d 3b pe = arTypes[x];
69f0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
6a00: 20 20 5f 72 65 67 69 73 74 65 72 65 64 46 75 6e _registeredFun
6a10: 63 74 69 6f 6e 73 2e 41 64 64 28 61 74 2c 20 6e ctions.Add(at, n
6a20: 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 ull);..
6a30: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
6a40: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 }..
6a50: 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 23 }.. }..#
6a60: 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 7d 0d 0a endif.. }..
6a70: 20 20 20 20 20 20 63 61 74 63 68 20 2f 2f 20 53 catch // S
6a80: 51 4c 69 74 65 20 70 72 6f 76 69 64 65 72 20 63 QLite provider c
6a90: 61 6e 20 63 6f 6e 74 69 6e 75 65 20 77 69 74 68 an continue with
6aa0: 6f 75 74 20 62 65 69 6e 67 20 61 62 6c 65 20 74 out being able t
6ab0: 6f 20 66 69 6e 64 20 62 75 69 6c 74 2d 69 6e 20 o find built-in
6ac0: 66 75 6e 63 74 69 6f 6e 73 0d 0a 20 20 20 20 20 functions..
6ad0: 20 7b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 {.. }..
6ae0: 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 }.... /// <s
6af0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
6b00: 20 4d 61 6e 75 61 6c 20 6d 65 74 68 6f 64 20 6f Manual method o
6b10: 66 20 72 65 67 69 73 74 65 72 69 6e 67 20 61 20 f registering a
6b20: 66 75 6e 63 74 69 6f 6e 2e 20 20 54 68 65 20 74 function. The t
6b30: 79 70 65 20 6d 75 73 74 20 73 74 69 6c 6c 20 68 ype must still h
6b40: 61 76 65 20 74 68 65 20 53 51 4c 69 74 65 46 75 ave the SQLiteFu
6b50: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 73 nctionAttributes
6b60: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 77 6f 72 in order to wor
6b70: 6b 0d 0a 20 20 20 20 2f 2f 2f 20 70 72 6f 70 65 k.. /// prope
6b80: 72 6c 79 2c 20 62 75 74 20 74 68 69 73 20 69 73 rly, but this is
6b90: 20 61 20 77 6f 72 6b 61 72 6f 75 6e 64 20 66 6f a workaround fo
6ba0: 72 20 74 68 65 20 43 6f 6d 70 61 63 74 20 46 72 r the Compact Fr
6bb0: 61 6d 65 77 6f 72 6b 20 77 68 65 72 65 20 65 6e amework where en
6bc0: 75 6d 65 72 61 74 69 6e 67 20 61 73 73 65 6d 62 umerating assemb
6bd0: 6c 69 65 73 20 69 73 20 6e 6f 74 20 63 75 72 72 lies is not curr
6be0: 65 6e 74 6c 79 20 73 75 70 70 6f 72 74 65 64 2e ently supported.
6bf0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
6c00: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
6c10: 61 72 61 6d 20 6e 61 6d 65 3d 22 74 79 70 22 3e aram name="typ">
6c20: 54 68 65 20 74 79 70 65 20 6f 66 20 74 68 65 20 The type of the
6c30: 66 75 6e 63 74 69 6f 6e 20 74 6f 20 72 65 67 69 function to regi
6c40: 73 74 65 72 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 ster</param>..
6c50: 20 20 70 75 62 6c 69 63 20 73 74 61 74 69 63 20 public static
6c60: 76 6f 69 64 20 52 65 67 69 73 74 65 72 46 75 6e void RegisterFun
6c70: 63 74 69 6f 6e 28 54 79 70 65 20 74 79 70 29 0d ction(Type typ).
6c80: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 6f 62 . {.. ob
6c90: 6a 65 63 74 5b 5d 20 61 72 41 74 74 20 3d 20 74 ject[] arAtt = t
6ca0: 79 70 2e 47 65 74 43 75 73 74 6f 6d 41 74 74 72 yp.GetCustomAttr
6cb0: 69 62 75 74 65 73 28 74 79 70 65 6f 66 28 53 51 ibutes(typeof(SQ
6cc0: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 LiteFunctionAttr
6cd0: 69 62 75 74 65 29 2c 20 66 61 6c 73 65 29 3b 0d ibute), false);.
6ce0: 0a 20 20 20 20 20 20 69 6e 74 20 75 20 3d 20 61 . int u = a
6cf0: 72 41 74 74 2e 4c 65 6e 67 74 68 3b 0d 0a 20 20 rAtt.Length;..
6d00: 20 20 20 20 53 51 4c 69 74 65 46 75 6e 63 74 69 SQLiteFuncti
6d10: 6f 6e 41 74 74 72 69 62 75 74 65 20 61 74 3b 0d onAttribute at;.
6d20: 0a 0d 0a 20 20 20 20 20 20 66 6f 72 20 28 69 6e ... for (in
6d30: 74 20 79 20 3d 20 30 3b 20 79 20 3c 20 75 3b 20 t y = 0; y < u;
6d40: 79 2b 2b 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 y++).. {..
6d50: 20 20 20 20 20 20 20 61 74 20 3d 20 61 72 41 74 at = arAt
6d60: 74 5b 79 5d 20 61 73 20 53 51 4c 69 74 65 46 75 t[y] as SQLiteFu
6d70: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 3b nctionAttribute;
6d80: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 61 74 .. if (at
6d90: 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 != null)..
6da0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
6db0: 61 74 2e 49 6e 73 74 61 6e 63 65 54 79 70 65 20 at.InstanceType
6dc0: 3d 20 74 79 70 3b 0d 0a 20 20 20 20 20 20 20 20 = typ;..
6dd0: 20 20 5f 72 65 67 69 73 74 65 72 65 64 46 75 6e _registeredFun
6de0: 63 74 69 6f 6e 73 2e 41 64 64 28 61 74 2c 20 6e ctions.Add(at, n
6df0: 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d ull);.. }
6e00: 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d .. }.. }
6e10: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
6e20: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 mary>.. /// C
6e30: 61 6c 6c 65 64 20 62 79 20 74 68 65 20 53 51 4c alled by the SQL
6e40: 69 74 65 42 61 73 65 20 64 65 72 69 76 65 64 20 iteBase derived
6e50: 63 6c 61 73 73 65 73 2c 20 74 68 69 73 20 6d 65 classes, this me
6e60: 74 68 6f 64 20 62 69 6e 64 73 20 61 6c 6c 20 72 thod binds all r
6e70: 65 67 69 73 74 65 72 65 64 20 28 6b 6e 6f 77 6e egistered (known
6e80: 29 20 75 73 65 72 2d 64 65 66 69 6e 65 64 20 66 ) user-defined f
6e90: 75 6e 63 74 69 6f 6e 73 20 74 6f 20 61 20 63 6f unctions to a co
6ea0: 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f nnection... /
6eb0: 2f 2f 20 49 74 20 69 73 20 64 6f 6e 65 20 74 68 // It is done th
6ec0: 69 73 20 77 61 79 20 73 6f 20 74 68 61 74 20 61 is way so that a
6ed0: 6c 6c 20 75 73 65 72 2d 64 65 66 69 6e 65 64 20 ll user-defined
6ee0: 66 75 6e 63 74 69 6f 6e 73 20 77 69 6c 6c 20 61 functions will a
6ef0: 63 63 65 73 73 20 74 68 65 20 64 61 74 61 62 61 ccess the databa
6f00: 73 65 20 75 73 69 6e 67 20 74 68 65 20 73 61 6d se using the sam
6f10: 65 20 65 6e 63 6f 64 69 6e 67 20 73 63 68 65 6d e encoding schem
6f20: 65 0d 0a 20 20 20 20 2f 2f 2f 20 61 73 20 74 68 e.. /// as th
6f30: 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 28 55 54 e connection (UT
6f40: 46 2d 38 20 6f 72 20 55 54 46 2d 31 36 29 2e 0d F-8 or UTF-16)..
6f50: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
6f60: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 ry>.. /// <re
6f70: 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 marks>.. ///
6f80: 54 68 65 20 77 72 61 70 70 65 72 20 66 75 6e 63 The wrapper func
6f90: 74 69 6f 6e 73 20 74 68 61 74 20 69 6e 74 65 72 tions that inter
6fa0: 6f 70 20 77 69 74 68 20 53 51 4c 69 74 65 20 77 op with SQLite w
6fb0: 69 6c 6c 20 63 72 65 61 74 65 20 61 20 75 6e 69 ill create a uni
6fc0: 71 75 65 20 63 6f 6f 6b 69 65 20 76 61 6c 75 65 que cookie value
6fd0: 2c 20 77 68 69 63 68 20 69 6e 74 65 72 6e 61 6c , which internal
6fe0: 6c 79 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 ly is a pointer
6ff0: 74 6f 0d 0a 20 20 20 20 2f 2f 2f 20 61 6c 6c 20 to.. /// all
7000: 74 68 65 20 77 72 61 70 70 65 64 20 63 61 6c 6c the wrapped call
7010: 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 73 2e 20 back functions.
7020: 20 54 68 65 20 69 6e 74 65 72 6f 70 20 66 75 6e The interop fun
7030: 63 74 69 6f 6e 20 75 73 65 73 20 69 74 20 74 6f ction uses it to
7040: 20 6d 61 70 20 43 44 65 63 6c 20 63 61 6c 6c 62 map CDecl callb
7050: 61 63 6b 73 20 74 6f 20 53 74 64 43 61 6c 6c 20 acks to StdCall
7060: 63 61 6c 6c 62 61 63 6b 73 2e 0d 0a 20 20 20 20 callbacks...
7070: 2f 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a /// </remarks>..
7080: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
7090: 61 6d 65 3d 22 73 71 6c 62 61 73 65 22 3e 54 68 ame="sqlbase">Th
70a0: 65 20 62 61 73 65 20 6f 62 6a 65 63 74 20 6f 6e e base object on
70b0: 20 77 68 69 63 68 20 74 68 65 20 66 75 6e 63 74 which the funct
70c0: 69 6f 6e 73 20 61 72 65 20 74 6f 20 62 69 6e 64 ions are to bind
70d0: 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f .</param>.. /
70e0: 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
70f0: 66 6c 61 67 73 22 3e 54 68 65 20 66 6c 61 67 73 flags">The flags
7100: 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 associated with
7110: 20 74 68 65 20 70 61 72 65 6e 74 20 63 6f 6e 6e the parent conn
7120: 65 63 74 69 6f 6e 20 6f 62 6a 65 63 74 2e 3c 2f ection object.</
7130: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
7140: 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 <returns>Returns
7150: 20 61 20 6c 6f 67 69 63 61 6c 20 6c 69 73 74 20 a logical list
7160: 6f 66 20 66 75 6e 63 74 69 6f 6e 73 20 77 68 69 of functions whi
7170: 63 68 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f ch the connectio
7180: 6e 20 73 68 6f 75 6c 64 20 72 65 74 61 69 6e 20 n should retain
7190: 75 6e 74 69 6c 20 69 74 20 69 73 20 63 6c 6f 73 until it is clos
71a0: 65 64 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 ed.</returns>..
71b0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 internal stat
71c0: 69 63 20 49 44 69 63 74 69 6f 6e 61 72 79 3c 53 ic IDictionary<S
71d0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
71e0: 72 69 62 75 74 65 2c 20 53 51 4c 69 74 65 46 75 ribute, SQLiteFu
71f0: 6e 63 74 69 6f 6e 3e 20 42 69 6e 64 46 75 6e 63 nction> BindFunc
7200: 74 69 6f 6e 73 28 0d 0a 20 20 20 20 20 20 20 20 tions(..
7210: 53 51 4c 69 74 65 42 61 73 65 20 73 71 6c 62 61 SQLiteBase sqlba
7220: 73 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 51 4c se,.. SQL
7230: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
7240: 67 73 20 66 6c 61 67 73 0d 0a 20 20 20 20 20 20 gs flags..
7250: 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ).. {..
7260: 20 20 20 20 49 44 69 63 74 69 6f 6e 61 72 79 3c IDictionary<
7270: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 SQLiteFunctionAt
7280: 74 72 69 62 75 74 65 2c 20 53 51 4c 69 74 65 46 tribute, SQLiteF
7290: 75 6e 63 74 69 6f 6e 3e 20 6c 46 75 6e 63 74 69 unction> lFuncti
72a0: 6f 6e 73 20 3d 0d 0a 20 20 20 20 20 20 20 20 20 ons =..
72b0: 20 20 20 6e 65 77 20 44 69 63 74 69 6f 6e 61 72 new Dictionar
72c0: 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e y<SQLiteFunction
72d0: 41 74 74 72 69 62 75 74 65 2c 20 53 51 4c 69 74 Attribute, SQLit
72e0: 65 46 75 6e 63 74 69 6f 6e 3e 28 29 3b 0d 0a 0d eFunction>();...
72f0: 0a 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 . foreach
7300: 20 28 4b 65 79 56 61 6c 75 65 50 61 69 72 3c 53 (KeyValuePair<S
7310: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
7320: 72 69 62 75 74 65 2c 20 6f 62 6a 65 63 74 3e 20 ribute, object>
7330: 70 61 69 72 0d 0a 20 20 20 20 20 20 20 20 20 20 pair..
7340: 20 20 20 20 20 20 69 6e 20 5f 72 65 67 69 73 74 in _regist
7350: 65 72 65 64 46 75 6e 63 74 69 6f 6e 73 29 0d 0a eredFunctions)..
7360: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
7370: 20 20 20 20 20 20 20 53 51 4c 69 74 65 46 75 6e SQLiteFun
7380: 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 20 70 ctionAttribute p
7390: 72 20 3d 20 70 61 69 72 2e 4b 65 79 3b 0d 0a 0d r = pair.Key;...
73a0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
73b0: 28 70 72 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 (pr == null)..
73c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f co
73d0: 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 ntinue;....
73e0: 20 20 20 20 20 20 20 53 51 4c 69 74 65 46 75 6e SQLiteFun
73f0: 63 74 69 6f 6e 20 66 20 3d 20 28 53 51 4c 69 74 ction f = (SQLit
7400: 65 46 75 6e 63 74 69 6f 6e 29 41 63 74 69 76 61 eFunction)Activa
7410: 74 6f 72 2e 43 72 65 61 74 65 49 6e 73 74 61 6e tor.CreateInstan
7420: 63 65 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ce(..
7430: 20 20 20 20 20 70 72 2e 49 6e 73 74 61 6e 63 65 pr.Instance
7440: 54 79 70 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 Type);....
7450: 20 20 20 20 20 20 42 69 6e 64 46 75 6e 63 74 69 BindFuncti
7460: 6f 6e 28 73 71 6c 62 61 73 65 2c 20 70 72 2c 20 on(sqlbase, pr,
7470: 66 2c 20 66 6c 61 67 73 29 3b 0d 0a 20 20 20 20 f, flags);..
7480: 20 20 20 20 20 20 20 20 6c 46 75 6e 63 74 69 6f lFunctio
7490: 6e 73 5b 70 72 5d 20 3d 20 66 3b 0d 0a 20 20 20 ns[pr] = f;..
74a0: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
74b0: 20 20 72 65 74 75 72 6e 20 6c 46 75 6e 63 74 69 return lFuncti
74c0: 6f 6e 73 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 ons;.. }....
74d0: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
74e0: 0d 0a 20 20 20 20 2f 2f 2f 20 43 61 6c 6c 65 64 .. /// Called
74f0: 20 62 79 20 74 68 65 20 53 51 4c 69 74 65 42 61 by the SQLiteBa
7500: 73 65 20 64 65 72 69 76 65 64 20 63 6c 61 73 73 se derived class
7510: 65 73 2c 20 74 68 69 73 20 6d 65 74 68 6f 64 20 es, this method
7520: 75 6e 62 69 6e 64 73 20 61 6c 6c 20 72 65 67 69 unbinds all regi
7530: 73 74 65 72 65 64 20 28 6b 6e 6f 77 6e 29 0d 0a stered (known)..
7540: 20 20 20 20 2f 2f 2f 20 66 75 6e 63 74 69 6f 6e /// function
7550: 73 20 2d 4f 52 2d 20 61 6c 6c 20 70 72 65 76 69 s -OR- all previ
7560: 6f 75 73 6c 79 20 62 6f 75 6e 64 20 75 73 65 72 ously bound user
7570: 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f -defined functio
7580: 6e 73 20 66 72 6f 6d 20 61 20 63 6f 6e 6e 65 63 ns from a connec
7590: 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c tion... /// <
75a0: 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f /summary>.. /
75b0: 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
75c0: 73 71 6c 62 61 73 65 22 3e 54 68 65 20 62 61 73 sqlbase">The bas
75d0: 65 20 6f 62 6a 65 63 74 20 66 72 6f 6d 20 77 68 e object from wh
75e0: 69 63 68 20 74 68 65 20 66 75 6e 63 74 69 6f 6e ich the function
75f0: 73 20 61 72 65 20 74 6f 20 62 65 20 75 6e 62 6f s are to be unbo
7600: 75 6e 64 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 und.</param>..
7610: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
7620: 65 3d 22 66 6c 61 67 73 22 3e 54 68 65 20 66 6c e="flags">The fl
7630: 61 67 73 20 61 73 73 6f 63 69 61 74 65 64 20 77 ags associated w
7640: 69 74 68 20 74 68 65 20 70 61 72 65 6e 74 20 63 ith the parent c
7650: 6f 6e 6e 65 63 74 69 6f 6e 20 6f 62 6a 65 63 74 onnection object
7660: 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f .</param>.. /
7670: 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
7680: 72 65 67 69 73 74 65 72 65 64 22 3e 0d 0a 20 20 registered">..
7690: 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 74 /// Non-zero t
76a0: 6f 20 75 6e 62 69 6e 64 20 61 6c 6c 20 72 65 67 o unbind all reg
76b0: 69 73 74 65 72 65 64 20 28 6b 6e 6f 77 6e 29 20 istered (known)
76c0: 66 75 6e 63 74 69 6f 6e 73 20 2d 4f 52 2d 20 7a functions -OR- z
76d0: 65 72 6f 20 74 6f 20 75 6e 62 69 6e 64 20 61 6c ero to unbind al
76e0: 6c 20 66 75 6e 63 74 69 6f 6e 73 0d 0a 20 20 20 l functions..
76f0: 20 2f 2f 2f 20 63 75 72 72 65 6e 74 6c 79 20 62 /// currently b
7700: 6f 75 6e 64 20 74 6f 20 74 68 65 20 63 6f 6e 6e ound to the conn
7710: 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f ection... ///
7720: 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f </param>.. /
7730: 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 4e 6f 6e 2d // <returns>Non-
7740: 7a 65 72 6f 20 69 66 20 61 6c 6c 20 74 68 65 20 zero if all the
7750: 73 70 65 63 69 66 69 65 64 20 75 73 65 72 2d 64 specified user-d
7760: 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e 73 efined functions
7770: 20 77 65 72 65 20 75 6e 62 6f 75 6e 64 2e 3c 2f were unbound.</
7780: 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
7790: 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 62 6f ternal static bo
77a0: 6f 6c 20 55 6e 62 69 6e 64 41 6c 6c 46 75 6e 63 ol UnbindAllFunc
77b0: 74 69 6f 6e 73 28 0d 0a 20 20 20 20 20 20 20 20 tions(..
77c0: 53 51 4c 69 74 65 42 61 73 65 20 73 71 6c 62 61 SQLiteBase sqlba
77d0: 73 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 51 4c se,.. SQL
77e0: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
77f0: 67 73 20 66 6c 61 67 73 2c 0d 0a 20 20 20 20 20 gs flags,..
7800: 20 20 20 62 6f 6f 6c 20 72 65 67 69 73 74 65 72 bool register
7810: 65 64 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 ed.. )..
7820: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 {.. if
7830: 20 28 73 71 6c 62 61 73 65 20 3d 3d 20 6e 75 6c (sqlbase == nul
7840: 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
7850: 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 0d return false;...
7860: 0a 20 20 20 20 20 20 20 20 49 44 69 63 74 69 6f . IDictio
7870: 6e 61 72 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 nary<SQLiteFunct
7880: 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 51 ionAttribute, SQ
7890: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 3e 20 6c 46 LiteFunction> lF
78a0: 75 6e 63 74 69 6f 6e 73 20 3d 0d 0a 20 20 20 20 unctions =..
78b0: 20 20 20 20 20 20 20 20 73 71 6c 62 61 73 65 2e sqlbase.
78c0: 46 75 6e 63 74 69 6f 6e 73 3b 0d 0a 0d 0a 20 20 Functions;....
78d0: 20 20 20 20 20 20 69 66 20 28 6c 46 75 6e 63 74 if (lFunct
78e0: 69 6f 6e 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 ions == null)..
78f0: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
7900: 6e 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 n false;....
7910: 20 20 20 20 62 6f 6f 6c 20 72 65 73 75 6c 74 20 bool result
7920: 3d 20 74 72 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 = true;....
7930: 20 20 20 69 66 20 28 72 65 67 69 73 74 65 72 65 if (registere
7940: 64 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 d).. {..
7950: 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 forea
7960: 63 68 20 28 4b 65 79 56 61 6c 75 65 50 61 69 72 ch (KeyValuePair
7970: 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 <SQLiteFunctionA
7980: 74 74 72 69 62 75 74 65 2c 20 6f 62 6a 65 63 74 ttribute, object
7990: 3e 20 70 61 69 72 0d 0a 20 20 20 20 20 20 20 20 > pair..
79a0: 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 20 5f in _
79b0: 72 65 67 69 73 74 65 72 65 64 46 75 6e 63 74 69 registeredFuncti
79c0: 6f 6e 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ons)..
79d0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
79e0: 20 20 20 20 20 53 51 4c 69 74 65 46 75 6e 63 74 SQLiteFunct
79f0: 69 6f 6e 41 74 74 72 69 62 75 74 65 20 70 72 20 ionAttribute pr
7a00: 3d 20 70 61 69 72 2e 4b 65 79 3b 0d 0a 0d 0a 20 = pair.Key;....
7a10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
7a20: 66 20 28 70 72 20 3d 3d 20 6e 75 6c 6c 29 0d 0a f (pr == null)..
7a30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7a40: 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d continue;...
7a50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
7a60: 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 SQLiteFunction
7a70: 66 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 f;....
7a80: 20 20 20 20 20 20 69 66 20 28 21 6c 46 75 6e 63 if (!lFunc
7a90: 74 69 6f 6e 73 2e 54 72 79 47 65 74 56 61 6c 75 tions.TryGetValu
7aa0: 65 28 70 72 2c 20 6f 75 74 20 66 29 20 7c 7c 0d e(pr, out f) ||.
7ab0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
7ac0: 20 20 20 20 20 28 66 20 3d 3d 20 6e 75 6c 6c 29 (f == null)
7ad0: 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ||..
7ae0: 20 20 20 20 20 20 20 20 20 21 55 6e 62 69 6e 64 !Unbind
7af0: 46 75 6e 63 74 69 6f 6e 28 73 71 6c 62 61 73 65 Function(sqlbase
7b00: 2c 20 70 72 2c 20 66 2c 20 66 6c 61 67 73 29 29 , pr, f, flags))
7b10: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
7b20: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
7b30: 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20 result
7b40: 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 = false;..
7b50: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
7b60: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
7b70: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 }.. e
7b80: 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a lse.. {..
7b90: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a //..
7ba0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e // N
7bb0: 4f 54 45 3a 20 4e 65 65 64 20 74 6f 20 75 73 65 OTE: Need to use
7bc0: 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 66 a copy of the f
7bd0: 75 6e 63 74 69 6f 6e 20 64 69 63 74 69 6f 6e 61 unction dictiona
7be0: 72 79 20 69 6e 20 74 68 69 73 20 6d 65 74 68 6f ry in this metho
7bf0: 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f d.. /
7c00: 2f 20 20 20 20 20 20 20 62 65 63 61 75 73 65 20 / because
7c10: 74 68 65 20 64 69 63 74 69 6f 6e 61 72 79 20 69 the dictionary i
7c20: 73 20 6d 6f 64 69 66 69 65 64 20 77 69 74 68 69 s modified withi
7c30: 6e 20 74 68 65 20 55 6e 62 69 6e 64 46 75 6e 63 n the UnbindFunc
7c40: 74 69 6f 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 tion..
7c50: 20 20 2f 2f 20 20 20 20 20 20 20 6d 65 74 68 6f // metho
7c60: 64 2c 20 77 68 69 63 68 20 69 73 20 63 61 6c 6c d, which is call
7c70: 65 64 20 69 6e 73 69 64 65 20 74 68 65 20 6c 6f ed inside the lo
7c80: 6f 70 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 op...
7c90: 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 //..
7ca0: 20 6c 46 75 6e 63 74 69 6f 6e 73 20 3d 20 6e 65 lFunctions = ne
7cb0: 77 20 44 69 63 74 69 6f 6e 61 72 79 3c 53 51 4c w Dictionary<SQL
7cc0: 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 iteFunctionAttri
7cd0: 62 75 74 65 2c 20 53 51 4c 69 74 65 46 75 6e 63 bute, SQLiteFunc
7ce0: 74 69 6f 6e 3e 28 0d 0a 20 20 20 20 20 20 20 20 tion>(..
7cf0: 20 20 20 20 20 20 20 20 6c 46 75 6e 63 74 69 6f lFunctio
7d00: 6e 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ns);....
7d10: 20 20 20 20 66 6f 72 65 61 63 68 20 28 4b 65 79 foreach (Key
7d20: 56 61 6c 75 65 50 61 69 72 3c 53 51 4c 69 74 65 ValuePair<SQLite
7d30: 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 FunctionAttribut
7d40: 65 2c 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f e, SQLiteFunctio
7d50: 6e 3e 20 70 61 69 72 0d 0a 20 20 20 20 20 20 20 n> pair..
7d60: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 20 in
7d70: 6c 46 75 6e 63 74 69 6f 6e 73 29 0d 0a 20 20 20 lFunctions)..
7d80: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
7d90: 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
7da0: 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 teFunctionAttrib
7db0: 75 74 65 20 70 72 20 3d 20 70 61 69 72 2e 4b 65 ute pr = pair.Ke
7dc0: 79 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 y;....
7dd0: 20 20 20 20 20 20 69 66 20 28 70 72 20 3d 3d 20 if (pr ==
7de0: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
7df0: 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 conti
7e00: 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 nue;....
7e10: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 46 75 SQLiteFu
7e20: 6e 63 74 69 6f 6e 20 66 20 3d 20 70 61 69 72 2e nction f = pair.
7e30: 56 61 6c 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 Value;....
7e40: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 66 if ((f
7e50: 20 3d 3d 20 6e 75 6c 6c 29 20 7c 7c 0d 0a 20 20 == null) ||..
7e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7e70: 20 20 21 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f !UnbindFunctio
7e80: 6e 28 73 71 6c 62 61 73 65 2c 20 70 72 2c 20 66 n(sqlbase, pr, f
7e90: 2c 20 66 6c 61 67 73 29 29 0d 0a 20 20 20 20 20 , flags))..
7ea0: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
7eb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7ec0: 20 20 72 65 73 75 6c 74 20 3d 20 66 61 6c 73 65 result = false
7ed0: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
7ee0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
7ef0: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a }.. }..
7f00: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
7f10: 20 72 65 73 75 6c 74 3b 0d 0a 20 20 20 20 7d 0d result;.. }.
7f20: 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ... /// <summ
7f30: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 ary>.. /// Th
7f40: 69 73 20 66 75 6e 63 74 69 6f 6e 20 62 69 6e 64 is function bind
7f50: 73 20 61 20 75 73 65 72 2d 64 65 66 69 6e 65 64 s a user-defined
7f60: 20 66 75 6e 63 74 69 6f 6e 73 20 74 6f 20 61 20 functions to a
7f70: 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 connection...
7f80: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
7f90: 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
7fa0: 6e 61 6d 65 3d 22 73 71 6c 69 74 65 42 61 73 65 name="sqliteBase
7fb0: 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
7fc0: 3c 73 65 65 20 63 72 65 66 3d 22 53 51 4c 69 74 <see cref="SQLit
7fd0: 65 42 61 73 65 22 20 2f 3e 20 6f 62 6a 65 63 74 eBase" /> object
7fe0: 20 69 6e 73 74 61 6e 63 65 20 61 73 73 6f 63 69 instance associ
7ff0: 61 74 65 64 20 77 69 74 68 20 74 68 65 0d 0a 20 ated with the..
8000: 20 20 20 2f 2f 2f 20 3c 73 65 65 20 63 72 65 66 /// <see cref
8010: 3d 22 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 ="SQLiteConnecti
8020: 6f 6e 22 20 2f 3e 20 74 68 61 74 20 74 68 65 20 on" /> that the
8030: 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 function should
8040: 62 65 20 62 6f 75 6e 64 20 74 6f 2e 0d 0a 20 20 be bound to...
8050: 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
8060: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
8070: 61 6d 65 3d 22 66 75 6e 63 74 69 6f 6e 41 74 74 ame="functionAtt
8080: 72 69 62 75 74 65 22 3e 0d 0a 20 20 20 20 2f 2f ribute">.. //
8090: 2f 20 54 68 65 20 3c 73 65 65 20 63 72 65 66 3d / The <see cref=
80a0: 22 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 "SQLiteFunctionA
80b0: 74 74 72 69 62 75 74 65 22 2f 3e 20 6f 62 6a 65 ttribute"/> obje
80c0: 63 74 20 69 6e 73 74 61 6e 63 65 20 63 6f 6e 74 ct instance cont
80d0: 61 69 6e 69 6e 67 0d 0a 20 20 20 20 2f 2f 2f 20 aining.. ///
80e0: 74 68 65 20 6d 65 74 61 64 61 74 61 20 66 6f 72 the metadata for
80f0: 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 74 6f the function to
8100: 20 62 65 20 62 6f 75 6e 64 2e 0d 0a 20 20 20 20 be bound...
8110: 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
8120: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
8130: 65 3d 22 66 75 6e 63 74 69 6f 6e 22 3e 0d 0a 20 e="function">..
8140: 20 20 20 2f 2f 2f 20 54 68 65 20 3c 73 65 65 20 /// The <see
8150: 63 72 65 66 3d 22 53 51 4c 69 74 65 46 75 6e 63 cref="SQLiteFunc
8160: 74 69 6f 6e 22 2f 3e 20 6f 62 6a 65 63 74 20 69 tion"/> object i
8170: 6e 73 74 61 6e 63 65 20 74 68 61 74 20 69 6d 70 nstance that imp
8180: 6c 65 6d 65 6e 74 73 20 74 68 65 0d 0a 20 20 20 lements the..
8190: 20 2f 2f 2f 20 66 75 6e 63 74 69 6f 6e 20 74 6f /// function to
81a0: 20 62 65 20 62 6f 75 6e 64 2e 0d 0a 20 20 20 20 be bound...
81b0: 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
81c0: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
81d0: 65 3d 22 66 6c 61 67 73 22 3e 0d 0a 20 20 20 20 e="flags">..
81e0: 2f 2f 2f 20 54 68 65 20 66 6c 61 67 73 20 61 73 /// The flags as
81f0: 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 sociated with th
8200: 65 20 70 61 72 65 6e 74 20 63 6f 6e 6e 65 63 74 e parent connect
8210: 69 6f 6e 20 6f 62 6a 65 63 74 2e 0d 0a 20 20 20 ion object...
8220: 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
8230: 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 internal stat
8240: 69 63 20 76 6f 69 64 20 42 69 6e 64 46 75 6e 63 ic void BindFunc
8250: 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 53 tion(.. S
8260: 51 4c 69 74 65 42 61 73 65 20 73 71 6c 69 74 65 QLiteBase sqlite
8270: 42 61 73 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 Base,.. S
8280: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
8290: 72 69 62 75 74 65 20 66 75 6e 63 74 69 6f 6e 41 ribute functionA
82a0: 74 74 72 69 62 75 74 65 2c 0d 0a 20 20 20 20 20 ttribute,..
82b0: 20 20 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f SQLiteFunctio
82c0: 6e 20 66 75 6e 63 74 69 6f 6e 2c 0d 0a 20 20 20 n function,..
82d0: 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 SQLiteConne
82e0: 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 ctionFlags flags
82f0: 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 20 20 .. )..
8300: 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 {.. if (
8310: 73 71 6c 69 74 65 42 61 73 65 20 3d 3d 20 6e 75 sqliteBase == nu
8320: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
8330: 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d throw new Argum
8340: 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e entNullException
8350: 28 22 73 71 6c 69 74 65 42 61 73 65 22 29 3b 0d ("sqliteBase");.
8360: 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 66 ... if (f
8370: 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 unctionAttribute
8380: 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
8390: 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
83a0: 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
83b0: 65 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e eption("function
83c0: 41 74 74 72 69 62 75 74 65 22 29 3b 0d 0a 0d 0a Attribute");....
83d0: 20 20 20 20 20 20 20 20 69 66 20 28 66 75 6e 63 if (func
83e0: 74 69 6f 6e 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 tion == null)..
83f0: 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
8400: 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c new ArgumentNul
8410: 6c 45 78 63 65 70 74 69 6f 6e 28 22 66 75 6e 63 lException("func
8420: 74 69 6f 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 tion");....
8430: 20 20 20 46 75 6e 63 74 69 6f 6e 54 79 70 65 20 FunctionType
8440: 66 75 6e 63 74 69 6f 6e 54 79 70 65 20 3d 20 66 functionType = f
8450: 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 unctionAttribute
8460: 2e 46 75 6e 63 54 79 70 65 3b 0d 0a 0d 0a 20 20 .FuncType;....
8470: 20 20 20 20 20 20 66 75 6e 63 74 69 6f 6e 2e 5f function._
8480: 62 61 73 65 20 3d 20 73 71 6c 69 74 65 42 61 73 base = sqliteBas
8490: 65 3b 0d 0a 20 20 20 20 20 20 20 20 66 75 6e 63 e;.. func
84a0: 74 69 6f 6e 2e 5f 66 6c 61 67 73 20 3d 20 66 6c tion._flags = fl
84b0: 61 67 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ags;....
84c0: 66 75 6e 63 74 69 6f 6e 2e 5f 49 6e 76 6f 6b 65 function._Invoke
84d0: 46 75 6e 63 20 3d 20 28 66 75 6e 63 74 69 6f 6e Func = (function
84e0: 54 79 70 65 20 3d 3d 20 46 75 6e 63 74 69 6f 6e Type == Function
84f0: 54 79 70 65 2e 53 63 61 6c 61 72 29 20 3f 0d 0a Type.Scalar) ?..
8500: 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 20 new
8510: 53 51 4c 69 74 65 43 61 6c 6c 62 61 63 6b 28 66 SQLiteCallback(f
8520: 75 6e 63 74 69 6f 6e 2e 53 63 61 6c 61 72 43 61 unction.ScalarCa
8530: 6c 6c 62 61 63 6b 29 20 3a 20 6e 75 6c 6c 3b 0d llback) : null;.
8540: 0a 0d 0a 20 20 20 20 20 20 20 20 66 75 6e 63 74 ... funct
8550: 69 6f 6e 2e 5f 53 74 65 70 46 75 6e 63 20 3d 20 ion._StepFunc =
8560: 28 66 75 6e 63 74 69 6f 6e 54 79 70 65 20 3d 3d (functionType ==
8570: 20 46 75 6e 63 74 69 6f 6e 54 79 70 65 2e 41 67 FunctionType.Ag
8580: 67 72 65 67 61 74 65 29 20 3f 0d 0a 20 20 20 20 gregate) ?..
8590: 20 20 20 20 20 20 20 20 6e 65 77 20 53 51 4c 69 new SQLi
85a0: 74 65 43 61 6c 6c 62 61 63 6b 28 66 75 6e 63 74 teCallback(funct
85b0: 69 6f 6e 2e 53 74 65 70 43 61 6c 6c 62 61 63 6b ion.StepCallback
85c0: 29 20 3a 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 ) : null;....
85d0: 20 20 20 20 20 66 75 6e 63 74 69 6f 6e 2e 5f 46 function._F
85e0: 69 6e 61 6c 46 75 6e 63 20 3d 20 28 66 75 6e 63 inalFunc = (func
85f0: 74 69 6f 6e 54 79 70 65 20 3d 3d 20 46 75 6e 63 tionType == Func
8600: 74 69 6f 6e 54 79 70 65 2e 41 67 67 72 65 67 61 tionType.Aggrega
8610: 74 65 29 20 3f 0d 0a 20 20 20 20 20 20 20 20 20 te) ?..
8620: 20 20 20 6e 65 77 20 53 51 4c 69 74 65 46 69 6e new SQLiteFin
8630: 61 6c 43 61 6c 6c 62 61 63 6b 28 66 75 6e 63 74 alCallback(funct
8640: 69 6f 6e 2e 46 69 6e 61 6c 43 61 6c 6c 62 61 63 ion.FinalCallbac
8650: 6b 29 20 3a 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 k) : null;....
8660: 20 20 20 20 20 20 66 75 6e 63 74 69 6f 6e 2e 5f function._
8670: 43 6f 6d 70 61 72 65 46 75 6e 63 20 3d 20 28 66 CompareFunc = (f
8680: 75 6e 63 74 69 6f 6e 54 79 70 65 20 3d 3d 20 46 unctionType == F
8690: 75 6e 63 74 69 6f 6e 54 79 70 65 2e 43 6f 6c 6c unctionType.Coll
86a0: 61 74 69 6f 6e 29 20 3f 0d 0a 20 20 20 20 20 20 ation) ?..
86b0: 20 20 20 20 20 20 6e 65 77 20 53 51 4c 69 74 65 new SQLite
86c0: 43 6f 6c 6c 61 74 69 6f 6e 28 66 75 6e 63 74 69 Collation(functi
86d0: 6f 6e 2e 43 6f 6d 70 61 72 65 43 61 6c 6c 62 61 on.CompareCallba
86e0: 63 6b 29 20 3a 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 ck) : null;....
86f0: 20 20 20 20 20 20 20 66 75 6e 63 74 69 6f 6e 2e function.
8700: 5f 43 6f 6d 70 61 72 65 46 75 6e 63 31 36 20 3d _CompareFunc16 =
8710: 20 28 66 75 6e 63 74 69 6f 6e 54 79 70 65 20 3d (functionType =
8720: 3d 20 46 75 6e 63 74 69 6f 6e 54 79 70 65 2e 43 = FunctionType.C
8730: 6f 6c 6c 61 74 69 6f 6e 29 20 3f 0d 0a 20 20 20 ollation) ?..
8740: 20 20 20 20 20 20 20 20 20 6e 65 77 20 53 51 4c new SQL
8750: 69 74 65 43 6f 6c 6c 61 74 69 6f 6e 28 66 75 6e iteCollation(fun
8760: 63 74 69 6f 6e 2e 43 6f 6d 70 61 72 65 43 61 6c ction.CompareCal
8770: 6c 62 61 63 6b 31 36 29 20 3a 20 6e 75 6c 6c 3b lback16) : null;
8780: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 73 74 72 69 .... stri
8790: 6e 67 20 6e 61 6d 65 20 3d 20 66 75 6e 63 74 69 ng name = functi
87a0: 6f 6e 41 74 74 72 69 62 75 74 65 2e 4e 61 6d 65 onAttribute.Name
87b0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
87c0: 28 66 75 6e 63 74 69 6f 6e 54 79 70 65 20 21 3d (functionType !=
87d0: 20 46 75 6e 63 74 69 6f 6e 54 79 70 65 2e 43 6f FunctionType.Co
87e0: 6c 6c 61 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 llation)..
87f0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
8800: 20 62 6f 6f 6c 20 6e 65 65 64 43 6f 6c 6c 53 65 bool needCollSe
8810: 71 20 3d 20 28 66 75 6e 63 74 69 6f 6e 20 69 73 q = (function is
8820: 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 45 SQLiteFunctionE
8830: 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 x);....
8840: 20 20 20 73 71 6c 69 74 65 42 61 73 65 2e 43 72 sqliteBase.Cr
8850: 65 61 74 65 46 75 6e 63 74 69 6f 6e 28 0d 0a 20 eateFunction(..
8860: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e n
8870: 61 6d 65 2c 20 66 75 6e 63 74 69 6f 6e 41 74 74 ame, functionAtt
8880: 72 69 62 75 74 65 2e 41 72 67 75 6d 65 6e 74 73 ribute.Arguments
8890: 2c 20 6e 65 65 64 43 6f 6c 6c 53 65 71 2c 0d 0a , needCollSeq,..
88a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
88b0: 66 75 6e 63 74 69 6f 6e 2e 5f 49 6e 76 6f 6b 65 function._Invoke
88c0: 46 75 6e 63 2c 20 66 75 6e 63 74 69 6f 6e 2e 5f Func, function._
88d0: 53 74 65 70 46 75 6e 63 2c 0d 0a 20 20 20 20 20 StepFunc,..
88e0: 20 20 20 20 20 20 20 20 20 20 20 66 75 6e 63 74 funct
88f0: 69 6f 6e 2e 5f 46 69 6e 61 6c 46 75 6e 63 2c 20 ion._FinalFunc,
8900: 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 true);..
8910: 7d 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 0d }.. else.
8920: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
8930: 20 20 20 20 20 20 20 20 73 71 6c 69 74 65 42 61 sqliteBa
8940: 73 65 2e 43 72 65 61 74 65 43 6f 6c 6c 61 74 69 se.CreateCollati
8950: 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 on(..
8960: 20 20 20 20 20 6e 61 6d 65 2c 20 66 75 6e 63 74 name, funct
8970: 69 6f 6e 2e 5f 43 6f 6d 70 61 72 65 46 75 6e 63 ion._CompareFunc
8980: 2c 20 66 75 6e 63 74 69 6f 6e 2e 5f 43 6f 6d 70 , function._Comp
8990: 61 72 65 46 75 6e 63 31 36 2c 0d 0a 20 20 20 20 areFunc16,..
89a0: 20 20 20 20 20 20 20 20 20 20 20 20 74 72 75 65 true
89b0: 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 );.. }..
89c0: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 }.... ///
89d0: 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f <summary>.. /
89e0: 2f 2f 20 54 68 69 73 20 66 75 6e 63 74 69 6f 6e // This function
89f0: 20 75 6e 62 69 6e 64 73 20 61 20 75 73 65 72 2d unbinds a user-
8a00: 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e defined function
8a10: 73 20 66 72 6f 6d 20 61 20 63 6f 6e 6e 65 63 74 s from a connect
8a20: 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ion... /// </
8a30: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
8a40: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 / <param name="s
8a50: 71 6c 69 74 65 42 61 73 65 22 3e 0d 0a 20 20 20 qliteBase">..
8a60: 20 2f 2f 2f 20 54 68 65 20 3c 73 65 65 20 63 72 /// The <see cr
8a70: 65 66 3d 22 53 51 4c 69 74 65 42 61 73 65 22 20 ef="SQLiteBase"
8a80: 2f 3e 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 6e /> object instan
8a90: 63 65 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 ce associated wi
8aa0: 74 68 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 th the.. ///
8ab0: 3c 73 65 65 20 63 72 65 66 3d 22 53 51 4c 69 74 <see cref="SQLit
8ac0: 65 43 6f 6e 6e 65 63 74 69 6f 6e 22 20 2f 3e 20 eConnection" />
8ad0: 74 68 61 74 20 74 68 65 20 66 75 6e 63 74 69 6f that the functio
8ae0: 6e 20 73 68 6f 75 6c 64 20 62 65 20 62 6f 75 6e n should be boun
8af0: 64 20 74 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c d to... /// <
8b00: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
8b10: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 <param name="fu
8b20: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 22 nctionAttribute"
8b30: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 3c >.. /// The <
8b40: 73 65 65 20 63 72 65 66 3d 22 53 51 4c 69 74 65 see cref="SQLite
8b50: 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 FunctionAttribut
8b60: 65 22 2f 3e 20 6f 62 6a 65 63 74 20 69 6e 73 74 e"/> object inst
8b70: 61 6e 63 65 20 63 6f 6e 74 61 69 6e 69 6e 67 0d ance containing.
8b80: 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 6d 65 74 . /// the met
8b90: 61 64 61 74 61 20 66 6f 72 20 74 68 65 20 66 75 adata for the fu
8ba0: 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f 75 nction to be bou
8bb0: 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 nd... /// </p
8bc0: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
8bd0: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 6e 63 param name="func
8be0: 74 69 6f 6e 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 tion">.. ///
8bf0: 54 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 53 The <see cref="S
8c00: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 22 2f 3e QLiteFunction"/>
8c10: 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 6e 63 65 object instance
8c20: 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 73 that implements
8c30: 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 75 the.. /// fu
8c40: 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f 75 nction to be bou
8c50: 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 nd... /// </p
8c60: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
8c70: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6c 61 67 param name="flag
8c80: 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 s">.. /// The
8c90: 20 66 6c 61 67 73 20 61 73 73 6f 63 69 61 74 65 flags associate
8ca0: 64 20 77 69 74 68 20 74 68 65 20 70 61 72 65 6e d with the paren
8cb0: 74 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 6f 62 6a t connection obj
8cc0: 65 63 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ect... /// </
8cd0: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
8ce0: 3c 72 65 74 75 72 6e 73 3e 4e 6f 6e 2d 7a 65 72 <returns>Non-zer
8cf0: 6f 20 69 66 20 74 68 65 20 66 75 6e 63 74 69 6f o if the functio
8d00: 6e 20 77 61 73 20 75 6e 62 6f 75 6e 64 2e 3c 2f n was unbound.</
8d10: 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
8d20: 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 62 6f ternal static bo
8d30: 6f 6c 20 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f ol UnbindFunctio
8d40: 6e 28 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 n(.. SQLi
8d50: 74 65 42 61 73 65 20 73 71 6c 69 74 65 42 61 73 teBase sqliteBas
8d60: 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 e,.. SQLi
8d70: 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 teFunctionAttrib
8d80: 75 74 65 20 66 75 6e 63 74 69 6f 6e 41 74 74 72 ute functionAttr
8d90: 69 62 75 74 65 2c 0d 0a 20 20 20 20 20 20 20 20 ibute,..
8da0: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 66 SQLiteFunction f
8db0: 75 6e 63 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 unction,..
8dc0: 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 SQLiteConnecti
8dd0: 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 20 2f 2a onFlags flags /*
8de0: 20 4e 4f 54 20 55 53 45 44 20 2a 2f 0d 0a 20 20 NOT USED */..
8df0: 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a ).. {..
8e00: 20 20 20 20 20 20 20 20 69 66 20 28 73 71 6c 69 if (sqli
8e10: 74 65 42 61 73 65 20 3d 3d 20 6e 75 6c 6c 29 0d teBase == null).
8e20: 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 . thr
8e30: 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e ow new ArgumentN
8e40: 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 22 73 71 ullException("sq
8e50: 6c 69 74 65 42 61 73 65 22 29 3b 0d 0a 0d 0a 20 liteBase");....
8e60: 20 20 20 20 20 20 20 69 66 20 28 66 75 6e 63 74 if (funct
8e70: 69 6f 6e 41 74 74 72 69 62 75 74 65 20 3d 3d 20 ionAttribute ==
8e80: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
8e90: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 throw new Arg
8ea0: 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 umentNullExcepti
8eb0: 6f 6e 28 22 66 75 6e 63 74 69 6f 6e 41 74 74 72 on("functionAttr
8ec0: 69 62 75 74 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 ibute");....
8ed0: 20 20 20 20 69 66 20 28 66 75 6e 63 74 69 6f 6e if (function
8ee0: 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
8ef0: 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
8f00: 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
8f10: 65 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e eption("function
8f20: 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 46 ");.... F
8f30: 75 6e 63 74 69 6f 6e 54 79 70 65 20 66 75 6e 63 unctionType func
8f40: 74 69 6f 6e 54 79 70 65 20 3d 20 66 75 6e 63 74 tionType = funct
8f50: 69 6f 6e 41 74 74 72 69 62 75 74 65 2e 46 75 6e ionAttribute.Fun
8f60: 63 54 79 70 65 3b 0d 0a 20 20 20 20 20 20 20 20 cType;..
8f70: 73 74 72 69 6e 67 20 6e 61 6d 65 20 3d 20 66 75 string name = fu
8f80: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2e nctionAttribute.
8f90: 4e 61 6d 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 Name;....
8fa0: 20 69 66 20 28 66 75 6e 63 74 69 6f 6e 54 79 70 if (functionTyp
8fb0: 65 20 21 3d 20 46 75 6e 63 74 69 6f 6e 54 79 70 e != FunctionTyp
8fc0: 65 2e 43 6f 6c 6c 61 74 69 6f 6e 29 0d 0a 20 20 e.Collation)..
8fd0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
8fe0: 20 20 20 20 20 62 6f 6f 6c 20 6e 65 65 64 43 6f bool needCo
8ff0: 6c 6c 53 65 71 20 3d 20 28 66 75 6e 63 74 69 6f llSeq = (functio
9000: 6e 20 69 73 20 53 51 4c 69 74 65 46 75 6e 63 74 n is SQLiteFunct
9010: 69 6f 6e 45 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 ionEx);....
9020: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 73 71 return sq
9030: 6c 69 74 65 42 61 73 65 2e 43 72 65 61 74 65 46 liteBase.CreateF
9040: 75 6e 63 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 unction(..
9050: 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 2c 20 name,
9060: 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 functionAttribut
9070: 65 2e 41 72 67 75 6d 65 6e 74 73 2c 20 6e 65 65 e.Arguments, nee
9080: 64 43 6f 6c 6c 53 65 71 2c 0d 0a 20 20 20 20 20 dCollSeq,..
9090: 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 2c null,
90a0: 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 66 61 6c null, null, fal
90b0: 73 65 29 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 se) == SQLiteErr
90c0: 6f 72 43 6f 64 65 2e 4f 6b 3b 0d 0a 20 20 20 20 orCode.Ok;..
90d0: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 }.. e
90e0: 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a lse.. {..
90f0: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
9100: 72 6e 20 73 71 6c 69 74 65 42 61 73 65 2e 43 72 rn sqliteBase.Cr
9110: 65 61 74 65 43 6f 6c 6c 61 74 69 6f 6e 28 0d 0a eateCollation(..
9120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
9130: 6e 61 6d 65 2c 20 6e 75 6c 6c 2c 20 6e 75 6c 6c name, null, null
9140: 2c 20 66 61 6c 73 65 29 20 3d 3d 20 53 51 4c 69 , false) == SQLi
9150: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 3b 0d teErrorCode.Ok;.
9160: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
9170: 7d 0d 0a 20 20 7d 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a }.. }..........
9180: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
9190: 0a 20 20 2f 2f 2f 20 45 78 74 65 6e 64 73 20 53 . /// Extends S
91a0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 61 6e QLiteFunction an
91b0: 64 20 61 6c 6c 6f 77 73 20 61 6e 20 69 6e 68 65 d allows an inhe
91c0: 72 69 74 65 64 20 63 6c 61 73 73 20 74 6f 20 6f rited class to o
91d0: 62 74 61 69 6e 20 74 68 65 20 63 6f 6c 6c 61 74 btain the collat
91e0: 69 6e 67 20 73 65 71 75 65 6e 63 65 20 61 73 73 ing sequence ass
91f0: 6f 63 69 61 74 65 64 20 77 69 74 68 20 61 20 66 ociated with a f
9200: 75 6e 63 74 69 6f 6e 20 63 61 6c 6c 2e 0d 0a 20 unction call...
9210: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
9220: 0a 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e . /// <remarks>
9230: 0d 0a 20 20 2f 2f 2f 20 55 73 65 72 2d 64 65 66 .. /// User-def
9240: 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e 73 20 63 ined functions c
9250: 61 6e 20 63 61 6c 6c 20 74 68 65 20 47 65 74 43 an call the GetC
9260: 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 ollationSequence
9270: 28 29 20 6d 65 74 68 6f 64 20 69 6e 20 74 68 69 () method in thi
9280: 73 20 63 6c 61 73 73 20 61 6e 64 20 75 73 65 20 s class and use
9290: 69 74 20 74 6f 20 63 6f 6d 70 61 72 65 20 73 74 it to compare st
92a0: 72 69 6e 67 73 20 61 6e 64 20 63 68 61 72 20 61 rings and char a
92b0: 72 72 61 79 73 2e 0d 0a 20 20 2f 2f 2f 20 3c 2f rrays... /// </
92c0: 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 70 75 62 6c remarks>.. publ
92d0: 69 63 20 63 6c 61 73 73 20 53 51 4c 69 74 65 46 ic class SQLiteF
92e0: 75 6e 63 74 69 6f 6e 45 78 20 3a 20 53 51 4c 69 unctionEx : SQLi
92f0: 74 65 46 75 6e 63 74 69 6f 6e 0d 0a 20 20 7b 0d teFunction.. {.
9300: 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
9310: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4f 62 74 61 y>.. /// Obta
9320: 69 6e 73 20 74 68 65 20 63 6f 6c 6c 61 74 69 6e ins the collatin
9330: 67 20 73 65 71 75 65 6e 63 65 20 69 6e 20 65 66 g sequence in ef
9340: 66 65 63 74 20 66 6f 72 20 74 68 65 20 67 69 76 fect for the giv
9350: 65 6e 20 66 75 6e 63 74 69 6f 6e 2e 0d 0a 20 20 en function...
9360: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
9370: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 .. /// <retur
9380: 6e 73 3e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 ns></returns>..
9390: 20 20 20 70 72 6f 74 65 63 74 65 64 20 43 6f 6c protected Col
93a0: 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 20 47 lationSequence G
93b0: 65 74 43 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 etCollationSeque
93c0: 6e 63 65 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 nce().. {..
93d0: 20 20 20 20 72 65 74 75 72 6e 20 5f 62 61 73 65 return _base
93e0: 2e 47 65 74 43 6f 6c 6c 61 74 69 6f 6e 53 65 71 .GetCollationSeq
93f0: 75 65 6e 63 65 28 74 68 69 73 2c 20 5f 63 6f 6e uence(this, _con
9400: 74 65 78 74 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d text);.. }...
9410: 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f . ///////////
9420: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9430: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9440: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9450: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9460: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9470: 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 23 72 65 67 ////.... #reg
9480: 69 6f 6e 20 49 44 69 73 70 6f 73 61 62 6c 65 20 ion IDisposable
9490: 22 50 61 74 74 65 72 6e 22 20 4d 65 6d 62 65 72 "Pattern" Member
94a0: 73 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 62 s.. private b
94b0: 6f 6f 6c 20 64 69 73 70 6f 73 65 64 3b 0d 0a 20 ool disposed;..
94c0: 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 private void
94d0: 43 68 65 63 6b 44 69 73 70 6f 73 65 64 28 29 20 CheckDisposed()
94e0: 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 /* throw */..
94f0: 20 7b 0d 0a 23 69 66 20 54 48 52 4f 57 5f 4f 4e {..#if THROW_ON
9500: 5f 44 49 53 50 4f 53 45 44 0d 0a 20 20 20 20 20 _DISPOSED..
9510: 20 20 20 69 66 20 28 64 69 73 70 6f 73 65 64 29 if (disposed)
9520: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 .. th
9530: 72 6f 77 20 6e 65 77 20 4f 62 6a 65 63 74 44 69 row new ObjectDi
9540: 73 70 6f 73 65 64 45 78 63 65 70 74 69 6f 6e 28 sposedException(
9550: 74 79 70 65 6f 66 28 53 51 4c 69 74 65 46 75 6e typeof(SQLiteFun
9560: 63 74 69 6f 6e 45 78 29 2e 4e 61 6d 65 29 3b 0d ctionEx).Name);.
9570: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a .#endif.. }..
9580: 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f .. //////////
9590: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
95a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
95b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
95c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
95d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
95e0: 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 70 72 6f /////.... pro
95f0: 74 65 63 74 65 64 20 6f 76 65 72 72 69 64 65 20 tected override
9600: 76 6f 69 64 20 44 69 73 70 6f 73 65 28 62 6f 6f void Dispose(boo
9610: 6c 20 64 69 73 70 6f 73 69 6e 67 29 0d 0a 20 20 l disposing)..
9620: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 74 72 79 {.. try
9630: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
9640: 20 20 20 20 20 20 20 20 20 69 66 20 28 21 64 69 if (!di
9650: 73 70 6f 73 65 64 29 0d 0a 20 20 20 20 20 20 20 sposed)..
9660: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
9670: 20 20 20 20 20 20 20 20 2f 2f 69 66 20 28 64 69 //if (di
9680: 73 70 6f 73 69 6e 67 29 0d 0a 20 20 20 20 20 20 sposing)..
9690: 20 20 20 20 20 20 20 20 20 20 2f 2f 7b 0d 0a 20 //{..
96a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
96b0: 2f 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f / ///////////
96c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
96d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 20 20 20 20 20 /////////..
96e0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 //
96f0: 20 2f 2f 20 64 69 73 70 6f 73 65 20 6d 61 6e 61 // dispose mana
9700: 67 65 64 20 72 65 73 6f 75 72 63 65 73 20 68 65 ged resources he
9710: 72 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 20 20 20 re.....
9720: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 2f 2f 2f // ///
9730: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9740: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9750: 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 /..
9760: 20 20 20 2f 2f 7d 0d 0a 0d 0a 20 20 20 20 20 20 //}....
9770: 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f //////
9780: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9790: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
97a0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
97b0: 20 20 2f 2f 20 72 65 6c 65 61 73 65 20 75 6e 6d // release unm
97c0: 61 6e 61 67 65 64 20 72 65 73 6f 75 72 63 65 73 anaged resources
97d0: 20 68 65 72 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 here.....
97e0: 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f //////
97f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9800: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9810: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d .. }.
9820: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
9830: 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 finally..
9840: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
9850: 20 20 20 20 62 61 73 65 2e 44 69 73 70 6f 73 65 base.Dispose
9860: 28 64 69 73 70 6f 73 69 6e 67 29 3b 0d 0a 0d 0a (disposing);....
9870: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a //..
9880: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e // N
9890: 4f 54 45 3a 20 45 76 65 72 79 74 68 69 6e 67 20 OTE: Everything
98a0: 73 68 6f 75 6c 64 20 62 65 20 66 75 6c 6c 79 20 should be fully
98b0: 64 69 73 70 6f 73 65 64 20 61 74 20 74 68 69 73 disposed at this
98c0: 20 70 6f 69 6e 74 2e 0d 0a 20 20 20 20 20 20 20 point...
98d0: 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 //..
98e0: 20 20 20 20 20 64 69 73 70 6f 73 65 64 20 3d 20 disposed =
98f0: 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d true;.. }
9900: 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 23 65 6e .. }.. #en
9910: 64 72 65 67 69 6f 6e 0d 0a 20 20 7d 0d 0a 0d 0a dregion.. }....
9920: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
9930: 0a 20 20 2f 2f 2f 20 54 68 65 20 74 79 70 65 20 . /// The type
9940: 6f 66 20 75 73 65 72 2d 64 65 66 69 6e 65 64 20 of user-defined
9950: 66 75 6e 63 74 69 6f 6e 20 74 6f 20 64 65 63 6c function to decl
9960: 61 72 65 0d 0a 20 20 2f 2f 2f 20 3c 2f 73 75 6d are.. /// </sum
9970: 6d 61 72 79 3e 0d 0a 20 20 70 75 62 6c 69 63 20 mary>.. public
9980: 65 6e 75 6d 20 46 75 6e 63 74 69 6f 6e 54 79 70 enum FunctionTyp
9990: 65 0d 0a 20 20 7b 0d 0a 20 20 20 20 2f 2f 2f 20 e.. {.. ///
99a0: 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f <summary>.. /
99b0: 2f 2f 20 53 63 61 6c 61 72 20 66 75 6e 63 74 69 // Scalar functi
99c0: 6f 6e 73 20 61 72 65 20 64 65 73 69 67 6e 65 64 ons are designed
99d0: 20 74 6f 20 62 65 20 63 61 6c 6c 65 64 20 61 6e to be called an
99e0: 64 20 72 65 74 75 72 6e 20 61 20 72 65 73 75 6c d return a resul
99f0: 74 20 69 6d 6d 65 64 69 61 74 65 6c 79 2e 20 20 t immediately.
9a00: 45 78 61 6d 70 6c 65 73 20 69 6e 63 6c 75 64 65 Examples include
9a10: 20 41 42 53 28 29 2c 20 55 70 70 65 72 28 29 2c ABS(), Upper(),
9a20: 20 4c 6f 77 65 72 28 29 2c 20 65 74 63 2e 0d 0a Lower(), etc...
9a30: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
9a40: 79 3e 0d 0a 20 20 20 20 53 63 61 6c 61 72 20 3d y>.. Scalar =
9a50: 20 30 2c 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 0,.. /// <su
9a60: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
9a70: 41 67 67 72 65 67 61 74 65 20 66 75 6e 63 74 69 Aggregate functi
9a80: 6f 6e 73 20 61 72 65 20 64 65 73 69 67 6e 65 64 ons are designed
9a90: 20 74 6f 20 61 63 63 75 6d 75 6c 61 74 65 20 64 to accumulate d
9aa0: 61 74 61 20 75 6e 74 69 6c 20 74 68 65 20 65 6e ata until the en
9ab0: 64 20 6f 66 20 61 20 63 61 6c 6c 20 61 6e 64 20 d of a call and
9ac0: 74 68 65 6e 20 72 65 74 75 72 6e 20 61 20 72 65 then return a re
9ad0: 73 75 6c 74 20 67 6c 65 61 6e 65 64 20 66 72 6f sult gleaned fro
9ae0: 6d 20 74 68 65 20 61 63 63 75 6d 75 6c 61 74 65 m the accumulate
9af0: 64 20 64 61 74 61 2e 0d 0a 20 20 20 20 2f 2f 2f d data... ///
9b00: 20 45 78 61 6d 70 6c 65 73 20 69 6e 63 6c 75 64 Examples includ
9b10: 65 20 53 55 4d 28 29 2c 20 43 4f 55 4e 54 28 29 e SUM(), COUNT()
9b20: 2c 20 41 56 47 28 29 2c 20 65 74 63 2e 0d 0a 20 , AVG(), etc...
9b30: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
9b40: 3e 0d 0a 20 20 20 20 41 67 67 72 65 67 61 74 65 >.. Aggregate
9b50: 20 3d 20 31 2c 0d 0a 20 20 20 20 2f 2f 2f 20 3c = 1,.. /// <
9b60: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
9b70: 2f 20 43 6f 6c 6c 61 74 69 6f 6e 20 73 65 71 75 / Collation sequ
9b80: 65 6e 63 65 73 20 61 72 65 20 75 73 65 64 20 74 ences are used t
9b90: 6f 20 73 6f 72 74 20 74 65 78 74 75 61 6c 20 64 o sort textual d
9ba0: 61 74 61 20 69 6e 20 61 20 63 75 73 74 6f 6d 20 ata in a custom
9bb0: 6d 61 6e 6e 65 72 2c 20 61 6e 64 20 61 70 70 65 manner, and appe
9bc0: 61 72 20 69 6e 20 61 6e 20 4f 52 44 45 52 20 42 ar in an ORDER B
9bd0: 59 20 63 6c 61 75 73 65 2e 20 20 54 79 70 69 63 Y clause. Typic
9be0: 61 6c 6c 79 20 74 65 78 74 20 69 6e 20 61 6e 20 ally text in an
9bf0: 4f 52 44 45 52 20 42 59 20 69 73 0d 0a 20 20 20 ORDER BY is..
9c00: 20 2f 2f 2f 20 73 6f 72 74 65 64 20 75 73 69 6e /// sorted usin
9c10: 67 20 61 20 73 74 72 61 69 67 68 74 20 63 61 73 g a straight cas
9c20: 65 2d 69 6e 73 65 6e 73 69 74 69 76 65 20 63 6f e-insensitive co
9c30: 6d 70 61 72 69 73 6f 6e 20 66 75 6e 63 74 69 6f mparison functio
9c40: 6e 2e 20 20 43 75 73 74 6f 6d 20 63 6f 6c 6c 61 n. Custom colla
9c50: 74 69 6e 67 20 73 65 71 75 65 6e 63 65 73 20 63 ting sequences c
9c60: 61 6e 20 62 65 20 75 73 65 64 20 74 6f 20 61 6c an be used to al
9c70: 74 65 72 20 74 68 65 20 62 65 68 61 76 69 6f 72 ter the behavior
9c80: 20 6f 66 20 74 65 78 74 20 73 6f 72 74 69 6e 67 of text sorting
9c90: 0d 0a 20 20 20 20 2f 2f 2f 20 69 6e 20 61 20 75 .. /// in a u
9ca0: 73 65 72 2d 64 65 66 69 6e 65 64 20 6d 61 6e 6e ser-defined mann
9cb0: 65 72 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 er... /// </s
9cc0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 43 6f 6c ummary>.. Col
9cd0: 6c 61 74 69 6f 6e 20 3d 20 32 2c 0d 0a 20 20 7d lation = 2,.. }
9ce0: 0d 0a 0d 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .... /// <summa
9cf0: 72 79 3e 0d 0a 20 20 2f 2f 2f 20 41 6e 20 69 6e ry>.. /// An in
9d00: 74 65 72 6e 61 6c 20 63 61 6c 6c 62 61 63 6b 20 ternal callback
9d10: 64 65 6c 65 67 61 74 65 20 64 65 63 6c 61 72 61 delegate declara
9d20: 74 69 6f 6e 2e 0d 0a 20 20 2f 2f 2f 20 3c 2f 73 tion... /// </s
9d30: 75 6d 6d 61 72 79 3e 0d 0a 20 20 2f 2f 2f 20 3c ummary>.. /// <
9d40: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 63 6f 6e 74 param name="cont
9d50: 65 78 74 22 3e 52 61 77 20 6e 61 74 69 76 65 20 ext">Raw native
9d60: 63 6f 6e 74 65 78 74 20 70 6f 69 6e 74 65 72 20 context pointer
9d70: 66 6f 72 20 74 68 65 20 75 73 65 72 20 66 75 6e for the user fun
9d80: 63 74 69 6f 6e 2e 3c 2f 70 61 72 61 6d 3e 0d 0a ction.</param>..
9d90: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
9da0: 65 3d 22 61 72 67 63 22 3e 54 6f 74 61 6c 20 6e e="argc">Total n
9db0: 75 6d 62 65 72 20 6f 66 20 61 72 67 75 6d 65 6e umber of argumen
9dc0: 74 73 20 74 6f 20 74 68 65 20 75 73 65 72 20 66 ts to the user f
9dd0: 75 6e 63 74 69 6f 6e 2e 3c 2f 70 61 72 61 6d 3e unction.</param>
9de0: 0d 0a 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e .. /// <param n
9df0: 61 6d 65 3d 22 61 72 67 76 22 3e 52 61 77 20 6e ame="argv">Raw n
9e00: 61 74 69 76 65 20 70 6f 69 6e 74 65 72 20 74 6f ative pointer to
9e10: 20 74 68 65 20 61 72 72 61 79 20 6f 66 20 72 61 the array of ra
9e20: 77 20 6e 61 74 69 76 65 20 61 72 67 75 6d 65 6e w native argumen
9e30: 74 20 70 6f 69 6e 74 65 72 73 2e 3c 2f 70 61 72 t pointers.</par
9e40: 61 6d 3e 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f am>..#if !PLATFO
9e50: 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 RM_COMPACTFRAMEW
9e60: 4f 52 4b 0d 0a 20 20 5b 55 6e 6d 61 6e 61 67 65 ORK.. [Unmanage
9e70: 64 46 75 6e 63 74 69 6f 6e 50 6f 69 6e 74 65 72 dFunctionPointer
9e80: 28 43 61 6c 6c 69 6e 67 43 6f 6e 76 65 6e 74 69 (CallingConventi
9e90: 6f 6e 2e 43 64 65 63 6c 29 5d 0d 0a 23 65 6e 64 on.Cdecl)]..#end
9ea0: 69 66 0d 0a 20 20 70 75 62 6c 69 63 20 64 65 6c if.. public del
9eb0: 65 67 61 74 65 20 76 6f 69 64 20 53 51 4c 69 74 egate void SQLit
9ec0: 65 43 61 6c 6c 62 61 63 6b 28 49 6e 74 50 74 72 eCallback(IntPtr
9ed0: 20 63 6f 6e 74 65 78 74 2c 20 69 6e 74 20 61 72 context, int ar
9ee0: 67 63 2c 20 49 6e 74 50 74 72 20 61 72 67 76 29 gc, IntPtr argv)
9ef0: 3b 0d 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 ;.. /// <summar
9f00: 79 3e 0d 0a 20 20 2f 2f 2f 20 41 6e 20 69 6e 74 y>.. /// An int
9f10: 65 72 6e 61 6c 20 66 69 6e 61 6c 20 63 61 6c 6c ernal final call
9f20: 62 61 63 6b 20 64 65 6c 65 67 61 74 65 20 64 65 back delegate de
9f30: 63 6c 61 72 61 74 69 6f 6e 2e 0d 0a 20 20 2f 2f claration... //
9f40: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
9f50: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
9f60: 22 63 6f 6e 74 65 78 74 22 3e 52 61 77 20 63 6f "context">Raw co
9f70: 6e 74 65 78 74 20 70 6f 69 6e 74 65 72 20 66 6f ntext pointer fo
9f80: 72 20 74 68 65 20 75 73 65 72 20 66 75 6e 63 74 r the user funct
9f90: 69 6f 6e 3c 2f 70 61 72 61 6d 3e 0d 0a 23 69 66 ion</param>..#if
9fa0: 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 !PLATFORM_COMPA
9fb0: 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 5b CTFRAMEWORK.. [
9fc0: 55 6e 6d 61 6e 61 67 65 64 46 75 6e 63 74 69 6f UnmanagedFunctio
9fd0: 6e 50 6f 69 6e 74 65 72 28 43 61 6c 6c 69 6e 67 nPointer(Calling
9fe0: 43 6f 6e 76 65 6e 74 69 6f 6e 2e 43 64 65 63 6c Convention.Cdecl
9ff0: 29 5d 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 69 6e )]..#endif.. in
a000: 74 65 72 6e 61 6c 20 64 65 6c 65 67 61 74 65 20 ternal delegate
a010: 76 6f 69 64 20 53 51 4c 69 74 65 46 69 6e 61 6c void SQLiteFinal
a020: 43 61 6c 6c 62 61 63 6b 28 49 6e 74 50 74 72 20 Callback(IntPtr
a030: 63 6f 6e 74 65 78 74 29 3b 0d 0a 20 20 2f 2f 2f context);.. ///
a040: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 2f 2f <summary>.. //
a050: 2f 20 49 6e 74 65 72 6e 61 6c 20 63 61 6c 6c 62 / Internal callb
a060: 61 63 6b 20 64 65 6c 65 67 61 74 65 20 66 6f 72 ack delegate for
a070: 20 69 6d 70 6c 65 6d 65 6e 74 69 6e 67 20 63 6f implementing co
a080: 6c 6c 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65 llation sequence
a090: 73 0d 0a 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 s.. /// </summa
a0a0: 72 79 3e 0d 0a 20 20 2f 2f 2f 20 3c 70 61 72 61 ry>.. /// <para
a0b0: 6d 20 6e 61 6d 65 3d 22 70 75 73 65 72 22 3e 4e m name="puser">N
a0c0: 6f 74 20 75 73 65 64 3c 2f 70 61 72 61 6d 3e 0d ot used</param>.
a0d0: 0a 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 . /// <param na
a0e0: 6d 65 3d 22 6c 65 6e 31 22 3e 4c 65 6e 67 74 68 me="len1">Length
a0f0: 20 6f 66 20 74 68 65 20 73 74 72 69 6e 67 20 70 of the string p
a100: 76 31 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 2f 2f v1</param>.. //
a110: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 / <param name="p
a120: 76 31 22 3e 50 6f 69 6e 74 65 72 20 74 6f 20 74 v1">Pointer to t
a130: 68 65 20 66 69 72 73 74 20 73 74 72 69 6e 67 20 he first string
a140: 74 6f 20 63 6f 6d 70 61 72 65 3c 2f 70 61 72 61 to compare</para
a150: 6d 3e 0d 0a 20 20 2f 2f 2f 20 3c 70 61 72 61 6d m>.. /// <param
a160: 20 6e 61 6d 65 3d 22 6c 65 6e 32 22 3e 4c 65 6e name="len2">Len
a170: 67 74 68 20 6f 66 20 74 68 65 20 73 74 72 69 6e gth of the strin
a180: 67 20 70 76 32 3c 2f 70 61 72 61 6d 3e 0d 0a 20 g pv2</param>..
a190: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
a1a0: 3d 22 70 76 32 22 3e 50 6f 69 6e 74 65 72 20 74 ="pv2">Pointer t
a1b0: 6f 20 74 68 65 20 73 65 63 6f 6e 64 20 73 74 72 o the second str
a1c0: 69 6e 67 20 74 6f 20 63 6f 6d 70 61 72 65 3c 2f ing to compare</
a1d0: 70 61 72 61 6d 3e 0d 0a 20 20 2f 2f 2f 20 3c 72 param>.. /// <r
a1e0: 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 20 2d eturns>Returns -
a1f0: 31 20 69 66 20 74 68 65 20 66 69 72 73 74 20 73 1 if the first s
a200: 74 72 69 6e 67 20 69 73 20 6c 65 73 73 20 74 68 tring is less th
a210: 61 6e 20 74 68 65 20 73 65 63 6f 6e 64 2e 20 20 an the second.
a220: 30 20 69 66 20 74 68 65 79 20 61 72 65 20 65 71 0 if they are eq
a230: 75 61 6c 2c 20 6f 72 20 31 20 69 66 20 74 68 65 ual, or 1 if the
a240: 20 66 69 72 73 74 20 73 74 72 69 6e 67 20 69 73 first string is
a250: 20 67 72 65 61 74 65 72 0d 0a 20 20 2f 2f 2f 20 greater.. ///
a260: 74 68 61 6e 20 74 68 65 20 73 65 63 6f 6e 64 2e than the second.
a270: 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 23 69 66 20 </returns>..#if
a280: 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 !PLATFORM_COMPAC
a290: 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 5b 55 TFRAMEWORK.. [U
a2a0: 6e 6d 61 6e 61 67 65 64 46 75 6e 63 74 69 6f 6e nmanagedFunction
a2b0: 50 6f 69 6e 74 65 72 28 43 61 6c 6c 69 6e 67 43 Pointer(CallingC
a2c0: 6f 6e 76 65 6e 74 69 6f 6e 2e 43 64 65 63 6c 29 onvention.Cdecl)
a2d0: 5d 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 69 6e 74 ]..#endif.. int
a2e0: 65 72 6e 61 6c 20 64 65 6c 65 67 61 74 65 20 69 ernal delegate i
a2f0: 6e 74 20 53 51 4c 69 74 65 43 6f 6c 6c 61 74 69 nt SQLiteCollati
a300: 6f 6e 28 49 6e 74 50 74 72 20 70 75 73 65 72 2c on(IntPtr puser,
a310: 20 69 6e 74 20 6c 65 6e 31 2c 20 49 6e 74 50 74 int len1, IntPt
a320: 72 20 70 76 31 2c 20 69 6e 74 20 6c 65 6e 32 2c r pv1, int len2,
a330: 20 49 6e 74 50 74 72 20 70 76 32 29 3b 0d 0a 0d IntPtr pv2);...
a340: 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e . /// <summary>
a350: 0d 0a 20 20 2f 2f 2f 20 54 68 65 20 74 79 70 65 .. /// The type
a360: 20 6f 66 20 63 6f 6c 6c 61 74 69 6e 67 20 73 65 of collating se
a370: 71 75 65 6e 63 65 0d 0a 20 20 2f 2f 2f 20 3c 2f quence.. /// </
a380: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 70 75 62 6c summary>.. publ
a390: 69 63 20 65 6e 75 6d 20 43 6f 6c 6c 61 74 69 6f ic enum Collatio
a3a0: 6e 54 79 70 65 45 6e 75 6d 0d 0a 20 20 7b 0d 0a nTypeEnum.. {..
a3b0: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
a3c0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 62 >.. /// The b
a3d0: 75 69 6c 74 2d 69 6e 20 42 49 4e 41 52 59 20 63 uilt-in BINARY c
a3e0: 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e 63 ollating sequenc
a3f0: 65 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d e.. /// </sum
a400: 6d 61 72 79 3e 0d 0a 20 20 20 20 42 69 6e 61 72 mary>.. Binar
a410: 79 20 3d 20 31 2c 0d 0a 20 20 20 20 2f 2f 2f 20 y = 1,.. ///
a420: 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f <summary>.. /
a430: 2f 2f 20 54 68 65 20 62 75 69 6c 74 2d 69 6e 20 // The built-in
a440: 4e 4f 43 41 53 45 20 63 6f 6c 6c 61 74 69 6e 67 NOCASE collating
a450: 20 73 65 71 75 65 6e 63 65 0d 0a 20 20 20 20 2f sequence.. /
a460: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
a470: 20 20 20 4e 6f 43 61 73 65 20 3d 20 32 2c 0d 0a NoCase = 2,..
a480: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
a490: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 62 >.. /// The b
a4a0: 75 69 6c 74 2d 69 6e 20 52 45 56 45 52 53 45 20 uilt-in REVERSE
a4b0: 63 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e collating sequen
a4c0: 63 65 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 ce.. /// </su
a4d0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 52 65 76 65 mmary>.. Reve
a4e0: 72 73 65 20 3d 20 33 2c 0d 0a 20 20 20 20 2f 2f rse = 3,.. //
a4f0: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
a500: 20 2f 2f 2f 20 41 20 63 75 73 74 6f 6d 20 75 73 /// A custom us
a510: 65 72 2d 64 65 66 69 6e 65 64 20 63 6f 6c 6c 61 er-defined colla
a520: 74 69 6e 67 20 73 65 71 75 65 6e 63 65 0d 0a 20 ting sequence..
a530: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
a540: 3e 0d 0a 20 20 20 20 43 75 73 74 6f 6d 20 3d 20 >.. Custom =
a550: 30 2c 0d 0a 20 20 7d 0d 0a 0d 0a 20 20 2f 2f 2f 0,.. }.... ///
a560: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 2f 2f <summary>.. //
a570: 2f 20 54 68 65 20 65 6e 63 6f 64 69 6e 67 20 74 / The encoding t
a580: 79 70 65 20 74 68 65 20 63 6f 6c 6c 61 74 69 6f ype the collatio
a590: 6e 20 73 65 71 75 65 6e 63 65 20 75 73 65 73 0d n sequence uses.
a5a0: 0a 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 . /// </summary
a5b0: 3e 0d 0a 20 20 70 75 62 6c 69 63 20 65 6e 75 6d >.. public enum
a5c0: 20 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 CollationEncodi
a5d0: 6e 67 45 6e 75 6d 0d 0a 20 20 7b 0d 0a 20 20 20 ngEnum.. {..
a5e0: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
a5f0: 20 20 20 20 2f 2f 2f 20 54 68 65 20 63 6f 6c 6c /// The coll
a600: 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65 20 69 ation sequence i
a610: 73 20 55 54 46 38 0d 0a 20 20 20 20 2f 2f 2f 20 s UTF8.. ///
a620: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
a630: 55 54 46 38 20 3d 20 31 2c 0d 0a 20 20 20 20 2f UTF8 = 1,.. /
a640: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
a650: 20 20 2f 2f 2f 20 54 68 65 20 63 6f 6c 6c 61 74 /// The collat
a660: 69 6f 6e 20 73 65 71 75 65 6e 63 65 20 69 73 20 ion sequence is
a670: 55 54 46 31 36 20 6c 69 74 74 6c 65 2d 65 6e 64 UTF16 little-end
a680: 69 61 6e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ian.. /// </s
a690: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 55 54 46 ummary>.. UTF
a6a0: 31 36 4c 45 20 3d 20 32 2c 0d 0a 20 20 20 20 2f 16LE = 2,.. /
a6b0: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
a6c0: 20 20 2f 2f 2f 20 54 68 65 20 63 6f 6c 6c 61 74 /// The collat
a6d0: 69 6f 6e 20 73 65 71 75 65 6e 63 65 20 69 73 20 ion sequence is
a6e0: 55 54 46 31 36 20 62 69 67 2d 65 6e 64 69 61 6e UTF16 big-endian
a6f0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
a700: 61 72 79 3e 0d 0a 20 20 20 20 55 54 46 31 36 42 ary>.. UTF16B
a710: 45 20 3d 20 33 2c 0d 0a 20 20 7d 0d 0a 0d 0a 20 E = 3,.. }....
a720: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
a730: 20 20 2f 2f 2f 20 41 20 73 74 72 75 63 74 20 64 /// A struct d
a740: 65 73 63 72 69 62 69 6e 67 20 74 68 65 20 63 6f escribing the co
a750: 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e 63 65 llating sequence
a760: 20 61 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 65 a function is e
a770: 78 65 63 75 74 69 6e 67 20 69 6e 0d 0a 20 20 2f xecuting in.. /
a780: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
a790: 20 70 75 62 6c 69 63 20 73 74 72 75 63 74 20 43 public struct C
a7a0: 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 ollationSequence
a7b0: 0d 0a 20 20 7b 0d 0a 20 20 20 20 2f 2f 2f 20 3c .. {.. /// <
a7c0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
a7d0: 2f 20 54 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 / The name of th
a7e0: 65 20 63 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 e collating sequ
a7f0: 65 6e 63 65 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ence.. /// </
a800: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 75 summary>.. pu
a810: 62 6c 69 63 20 73 74 72 69 6e 67 20 4e 61 6d 65 blic string Name
a820: 3b 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ;.. /// <summ
a830: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 ary>.. /// Th
a840: 65 20 74 79 70 65 20 6f 66 20 63 6f 6c 6c 61 74 e type of collat
a850: 69 6e 67 20 73 65 71 75 65 6e 63 65 0d 0a 20 20 ing sequence..
a860: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
a870: 0d 0a 20 20 20 20 70 75 62 6c 69 63 20 43 6f 6c .. public Col
a880: 6c 61 74 69 6f 6e 54 79 70 65 45 6e 75 6d 20 54 lationTypeEnum T
a890: 79 70 65 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 ype;.... ///
a8a0: 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f <summary>.. /
a8b0: 2f 2f 20 54 68 65 20 74 65 78 74 20 65 6e 63 6f // The text enco
a8c0: 64 69 6e 67 20 6f 66 20 74 68 65 20 63 6f 6c 6c ding of the coll
a8d0: 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65 0d 0a ation sequence..
a8e0: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
a8f0: 79 3e 0d 0a 20 20 20 20 70 75 62 6c 69 63 20 43 y>.. public C
a900: 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 ollationEncoding
a910: 45 6e 75 6d 20 45 6e 63 6f 64 69 6e 67 3b 0d 0a Enum Encoding;..
a920: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
a930: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 6f 6e ry>.. /// Con
a940: 74 65 78 74 20 6f 66 20 74 68 65 20 66 75 6e 63 text of the func
a950: 74 69 6f 6e 20 74 68 61 74 20 72 65 71 75 65 73 tion that reques
a960: 74 65 64 20 74 68 65 20 63 6f 6c 6c 61 74 69 6e ted the collatin
a970: 67 20 73 65 71 75 65 6e 63 65 0d 0a 20 20 20 20 g sequence..
a980: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
a990: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 53 51 4c internal SQL
a9a0: 69 74 65 46 75 6e 63 74 69 6f 6e 20 5f 66 75 6e iteFunction _fun
a9b0: 63 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 c;.... /// <s
a9c0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
a9d0: 20 43 61 6c 6c 73 20 74 68 65 20 62 61 73 65 20 Calls the base
a9e0: 63 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e collating sequen
a9f0: 63 65 20 74 6f 20 63 6f 6d 70 61 72 65 20 74 77 ce to compare tw
aa00: 6f 20 73 74 72 69 6e 67 73 0d 0a 20 20 20 20 2f o strings.. /
aa10: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
aa20: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
aa30: 6d 65 3d 22 73 31 22 3e 54 68 65 20 66 69 72 73 me="s1">The firs
aa40: 74 20 73 74 72 69 6e 67 20 74 6f 20 63 6f 6d 70 t string to comp
aa50: 61 72 65 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 are</param>..
aa60: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
aa70: 3d 22 73 32 22 3e 54 68 65 20 73 65 63 6f 6e 64 ="s2">The second
aa80: 20 73 74 72 69 6e 67 20 74 6f 20 63 6f 6d 70 61 string to compa
aa90: 72 65 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 re</param>..
aaa0: 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 2d 31 20 /// <returns>-1
aab0: 69 66 20 73 31 20 69 73 20 6c 65 73 73 20 74 68 if s1 is less th
aac0: 61 6e 20 73 32 2c 20 30 20 69 66 20 73 31 20 69 an s2, 0 if s1 i
aad0: 73 20 65 71 75 61 6c 20 74 6f 20 73 32 2c 20 61 s equal to s2, a
aae0: 6e 64 20 31 20 69 66 20 73 31 20 69 73 20 67 72 nd 1 if s1 is gr
aaf0: 65 61 74 65 72 20 74 68 61 6e 20 73 32 3c 2f 72 eater than s2</r
ab00: 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 70 75 62 eturns>.. pub
ab10: 6c 69 63 20 69 6e 74 20 43 6f 6d 70 61 72 65 28 lic int Compare(
ab20: 73 74 72 69 6e 67 20 73 31 2c 20 73 74 72 69 6e string s1, strin
ab30: 67 20 73 32 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 g s2).. {..
ab40: 20 20 20 20 72 65 74 75 72 6e 20 5f 66 75 6e 63 return _func
ab50: 2e 5f 62 61 73 65 2e 43 6f 6e 74 65 78 74 43 6f ._base.ContextCo
ab60: 6c 6c 61 74 65 43 6f 6d 70 61 72 65 28 45 6e 63 llateCompare(Enc
ab70: 6f 64 69 6e 67 2c 20 5f 66 75 6e 63 2e 5f 63 6f oding, _func._co
ab80: 6e 74 65 78 74 2c 20 73 31 2c 20 73 32 29 3b 0d ntext, s1, s2);.
ab90: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
aba0: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
abb0: 20 2f 2f 2f 20 43 61 6c 6c 73 20 74 68 65 20 62 /// Calls the b
abc0: 61 73 65 20 63 6f 6c 6c 61 74 69 6e 67 20 73 65 ase collating se
abd0: 71 75 65 6e 63 65 20 74 6f 20 63 6f 6d 70 61 72 quence to compar
abe0: 65 20 74 77 6f 20 63 68 61 72 61 63 74 65 72 20 e two character
abf0: 61 72 72 61 79 73 0d 0a 20 20 20 20 2f 2f 2f 20 arrays.. ///
ac00: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
ac10: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
ac20: 22 63 31 22 3e 54 68 65 20 66 69 72 73 74 20 61 "c1">The first a
ac30: 72 72 61 79 20 74 6f 20 63 6f 6d 70 61 72 65 3c rray to compare<
ac40: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
ac50: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 63 32 <param name="c2
ac60: 22 3e 54 68 65 20 73 65 63 6f 6e 64 20 61 72 72 ">The second arr
ac70: 61 79 20 74 6f 20 63 6f 6d 70 61 72 65 3c 2f 70 ay to compare</p
ac80: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
ac90: 72 65 74 75 72 6e 73 3e 2d 31 20 69 66 20 63 31 returns>-1 if c1
aca0: 20 69 73 20 6c 65 73 73 20 74 68 61 6e 20 63 32 is less than c2
acb0: 2c 20 30 20 69 66 20 63 31 20 69 73 20 65 71 75 , 0 if c1 is equ
acc0: 61 6c 20 74 6f 20 63 32 2c 20 61 6e 64 20 31 20 al to c2, and 1
acd0: 69 66 20 63 31 20 69 73 20 67 72 65 61 74 65 72 if c1 is greater
ace0: 20 74 68 61 6e 20 63 32 3c 2f 72 65 74 75 72 6e than c2</return
acf0: 73 3e 0d 0a 20 20 20 20 70 75 62 6c 69 63 20 69 s>.. public i
ad00: 6e 74 20 43 6f 6d 70 61 72 65 28 63 68 61 72 5b nt Compare(char[
ad10: 5d 20 63 31 2c 20 63 68 61 72 5b 5d 20 63 32 29 ] c1, char[] c2)
ad20: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 .. {.. r
ad30: 65 74 75 72 6e 20 5f 66 75 6e 63 2e 5f 62 61 73 eturn _func._bas
ad40: 65 2e 43 6f 6e 74 65 78 74 43 6f 6c 6c 61 74 65 e.ContextCollate
ad50: 43 6f 6d 70 61 72 65 28 45 6e 63 6f 64 69 6e 67 Compare(Encoding
ad60: 2c 20 5f 66 75 6e 63 2e 5f 63 6f 6e 74 65 78 74 , _func._context
ad70: 2c 20 63 31 2c 20 63 32 29 3b 0d 0a 20 20 20 20 , c1, c2);..
ad80: 7d 0d 0a 20 20 7d 0d 0a 7d 0d 0a }.. }..}..