Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improve use of object hash codes by the SQLiteModuleEnumerable class. Clarify via comments that methods of the SQLiteNativeModule class are exempt from using CheckDisposed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5a605c351d50d0e13f414146cf579335 |
User & Date: | mistachkin 2014-02-05 20:26:50.583 |
Context
2014-02-05
| ||
21:00 | Add more tests. check-in: dc9d065888 user: mistachkin tags: trunk | |
20:26 | Improve use of object hash codes by the SQLiteModuleEnumerable class. Clarify via comments that methods of the SQLiteNativeModule class are exempt from using CheckDisposed. check-in: 5a605c351d user: mistachkin tags: trunk | |
01:46 | Update table-of-contents topic names. check-in: 837439ff91 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteModule.cs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Joe Mistachkin (joe@mistachkin.com) * * Released to the public domain, use at your own risk! ********************************************************/ using System.Collections.Generic; using System.Globalization; using System.Runtime.InteropServices; using System.Text; namespace System.Data.SQLite { #region SQLiteContext Helper Class /// <summary> | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Joe Mistachkin (joe@mistachkin.com) * * Released to the public domain, use at your own risk! ********************************************************/ using System.Collections.Generic; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; namespace System.Data.SQLite { #region SQLiteContext Helper Class /// <summary> |
︙ | ︙ | |||
4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 | #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteIntPtr(pointer, offset, value); #else Marshal.WriteIntPtr(IntPtrForOffset(pointer, offset), value); #endif } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteModule Base Class /// <summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 | #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteIntPtr(pointer, offset, value); #else Marshal.WriteIntPtr(IntPtrForOffset(pointer, offset), value); #endif } #endregion /////////////////////////////////////////////////////////////////////// #region Object Helper Methods /// <summary> /// Generates a hash code value for the object. /// </summary> /// <param name="value"> /// The object instance used to calculate the hash code. /// </param> /// <param name="identity"> /// Non-zero if different object instances with the same value should /// generate different hash codes, where applicable. This parameter /// has no effect on the .NET Compact Framework. /// </param> /// <returns> /// The hash code value -OR- zero if the object is null. /// </returns> public static int GetHashCode( object value, bool identity ) { #if !PLATFORM_COMPACTFRAMEWORK if (identity) return RuntimeHelpers.GetHashCode(value); #endif if (value == null) return 0; return value.GetHashCode(); } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteModule Base Class /// <summary> |
︙ | ︙ | |||
4691 4692 4693 4694 4695 4696 4697 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { | > > > | | 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) { pError = SQLiteString.Utf8IntPtrFromString( ModuleNotAvailableErrorMessage); return SQLiteErrorCode.Error; |
︙ | ︙ | |||
4740 4741 4742 4743 4744 4745 4746 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { | > > > | | 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) { pError = SQLiteString.Utf8IntPtrFromString( ModuleNotAvailableErrorMessage); return SQLiteErrorCode.Error; |
︙ | ︙ | |||
4773 4774 4775 4776 4777 4778 4779 | /// See the <see cref="ISQLiteNativeModule.xBestIndex" /> method. /// </returns> public SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr pIndex ) { | > > > | | 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 | /// See the <see cref="ISQLiteNativeModule.xBestIndex" /> method. /// </returns> public SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr pIndex ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xBestIndex(pVtab, pIndex); } |
︙ | ︙ | |||
4796 4797 4798 4799 4800 4801 4802 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDisconnect" /> method. /// </returns> public SQLiteErrorCode xDisconnect( IntPtr pVtab ) { | > > > | | 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDisconnect" /> method. /// </returns> public SQLiteErrorCode xDisconnect( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xDisconnect(pVtab); } |
︙ | ︙ | |||
4819 4820 4821 4822 4823 4824 4825 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDestroy" /> method. /// </returns> public SQLiteErrorCode xDestroy( IntPtr pVtab ) { | > > > | | 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDestroy" /> method. /// </returns> public SQLiteErrorCode xDestroy( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xDestroy(pVtab); } |
︙ | ︙ | |||
4846 4847 4848 4849 4850 4851 4852 | /// See the <see cref="ISQLiteNativeModule.xOpen" /> method. /// </returns> public SQLiteErrorCode xOpen( IntPtr pVtab, ref IntPtr pCursor ) { | > > > | | 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 | /// See the <see cref="ISQLiteNativeModule.xOpen" /> method. /// </returns> public SQLiteErrorCode xOpen( IntPtr pVtab, ref IntPtr pCursor ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xOpen(pVtab, ref pCursor); } |
︙ | ︙ | |||
4869 4870 4871 4872 4873 4874 4875 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xClose" /> method. /// </returns> public SQLiteErrorCode xClose( IntPtr pCursor ) { | > > > | | 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xClose" /> method. /// </returns> public SQLiteErrorCode xClose( IntPtr pCursor ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableCursorError(pCursor); return module.xClose(pCursor); } |
︙ | ︙ | |||
4908 4909 4910 4911 4912 4913 4914 | IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr argv ) { | > > > | | 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 | IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr argv ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableCursorError(pCursor); return module.xFilter(pCursor, idxNum, idxStr, argc, argv); } |
︙ | ︙ | |||
4931 4932 4933 4934 4935 4936 4937 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xNext" /> method. /// </returns> public SQLiteErrorCode xNext( IntPtr pCursor ) { | > > > | | 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xNext" /> method. /// </returns> public SQLiteErrorCode xNext( IntPtr pCursor ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableCursorError(pCursor); return module.xNext(pCursor); } |
︙ | ︙ | |||
4954 4955 4956 4957 4958 4959 4960 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xEof" /> method. /// </returns> public int xEof( IntPtr pCursor ) { | > > > | | 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xEof" /> method. /// </returns> public int xEof( IntPtr pCursor ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) { ModuleNotAvailableCursorError(pCursor); return 1; } |
︙ | ︙ | |||
4988 4989 4990 4991 4992 4993 4994 | /// </returns> public SQLiteErrorCode xColumn( IntPtr pCursor, IntPtr pContext, int index ) { | > > > | | 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 | /// </returns> public SQLiteErrorCode xColumn( IntPtr pCursor, IntPtr pContext, int index ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableCursorError(pCursor); return module.xColumn(pCursor, pContext, index); } |
︙ | ︙ | |||
5015 5016 5017 5018 5019 5020 5021 | /// See the <see cref="ISQLiteNativeModule.xRowId" /> method. /// </returns> public SQLiteErrorCode xRowId( IntPtr pCursor, ref long rowId ) { | > > > | | 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 | /// See the <see cref="ISQLiteNativeModule.xRowId" /> method. /// </returns> public SQLiteErrorCode xRowId( IntPtr pCursor, ref long rowId ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableCursorError(pCursor); return module.xRowId(pCursor, ref rowId); } |
︙ | ︙ | |||
5050 5051 5052 5053 5054 5055 5056 | public SQLiteErrorCode xUpdate( IntPtr pVtab, int argc, IntPtr argv, ref long rowId ) { | > > > | | 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 | public SQLiteErrorCode xUpdate( IntPtr pVtab, int argc, IntPtr argv, ref long rowId ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xUpdate(pVtab, argc, argv, ref rowId); } |
︙ | ︙ | |||
5073 5074 5075 5076 5077 5078 5079 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xBegin" /> method. /// </returns> public SQLiteErrorCode xBegin( IntPtr pVtab ) { | > > > | | 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xBegin" /> method. /// </returns> public SQLiteErrorCode xBegin( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xBegin(pVtab); } |
︙ | ︙ | |||
5096 5097 5098 5099 5100 5101 5102 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xSync" /> method. /// </returns> public SQLiteErrorCode xSync( IntPtr pVtab ) { | > > > | | 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xSync" /> method. /// </returns> public SQLiteErrorCode xSync( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xSync(pVtab); } |
︙ | ︙ | |||
5119 5120 5121 5122 5123 5124 5125 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xCommit" /> method. /// </returns> public SQLiteErrorCode xCommit( IntPtr pVtab ) { | > > > | | 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xCommit" /> method. /// </returns> public SQLiteErrorCode xCommit( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xCommit(pVtab); } |
︙ | ︙ | |||
5142 5143 5144 5145 5146 5147 5148 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xRollback" /> method. /// </returns> public SQLiteErrorCode xRollback( IntPtr pVtab ) { | > > > | | 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xRollback" /> method. /// </returns> public SQLiteErrorCode xRollback( IntPtr pVtab ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xRollback(pVtab); } |
︙ | ︙ | |||
5181 5182 5183 5184 5185 5186 5187 | IntPtr pVtab, int nArg, IntPtr zName, ref SQLiteCallback callback, ref IntPtr pClientData ) { | > > > | | 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 | IntPtr pVtab, int nArg, IntPtr zName, ref SQLiteCallback callback, ref IntPtr pClientData ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) { ModuleNotAvailableTableError(pVtab); return 0; } |
︙ | ︙ | |||
5212 5213 5214 5215 5216 5217 5218 | /// See the <see cref="ISQLiteNativeModule.xRename" /> method. /// </returns> public SQLiteErrorCode xRename( IntPtr pVtab, IntPtr zNew ) { | > > > | | 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 | /// See the <see cref="ISQLiteNativeModule.xRename" /> method. /// </returns> public SQLiteErrorCode xRename( IntPtr pVtab, IntPtr zNew ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xRename(pVtab, zNew); } |
︙ | ︙ | |||
5239 5240 5241 5242 5243 5244 5245 | /// See the <see cref="ISQLiteNativeModule.xSavepoint" /> method. /// </returns> public SQLiteErrorCode xSavepoint( IntPtr pVtab, int iSavepoint ) { | > > > | | 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 | /// See the <see cref="ISQLiteNativeModule.xSavepoint" /> method. /// </returns> public SQLiteErrorCode xSavepoint( IntPtr pVtab, int iSavepoint ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xSavepoint(pVtab, iSavepoint); } |
︙ | ︙ | |||
5266 5267 5268 5269 5270 5271 5272 | /// See the <see cref="ISQLiteNativeModule.xRelease" /> method. /// </returns> public SQLiteErrorCode xRelease( IntPtr pVtab, int iSavepoint ) { | > > > | | 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 | /// See the <see cref="ISQLiteNativeModule.xRelease" /> method. /// </returns> public SQLiteErrorCode xRelease( IntPtr pVtab, int iSavepoint ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xRelease(pVtab, iSavepoint); } |
︙ | ︙ | |||
5293 5294 5295 5296 5297 5298 5299 | /// See the <see cref="ISQLiteNativeModule.xRollbackTo" /> method. /// </returns> public SQLiteErrorCode xRollbackTo( IntPtr pVtab, int iSavepoint ) { | > > > | | 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 | /// See the <see cref="ISQLiteNativeModule.xRollbackTo" /> method. /// </returns> public SQLiteErrorCode xRollbackTo( IntPtr pVtab, int iSavepoint ) { // // NOTE: Called by native code. // // CheckDisposed(); /* EXEMPT */ if (module == null) return ModuleNotAvailableTableError(pVtab); return module.xRollbackTo(pVtab, iSavepoint); } #endregion |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteModuleEnumerable.cs.
︙ | ︙ | |||
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | #region Private Data /// <summary> /// The <see cref="IEnumerable" /> instance containing the backing data /// for the virtual table. /// </summary> private IEnumerable enumerable; #endregion /////////////////////////////////////////////////////////////////////// #region Public Constructors /// <summary> /// Constructs an instance of this class. /// </summary> /// <param name="name"> /// The name of the module. This parameter cannot be null. /// </param> /// <param name="enumerable"> /// The <see cref="IEnumerable" /> instance to expose as a virtual /// table. This parameter cannot be null. /// </param> public SQLiteModuleEnumerable( string name, IEnumerable enumerable ) : base(name) { if (enumerable == null) throw new ArgumentNullException("enumerable"); this.enumerable = enumerable; } #endregion /////////////////////////////////////////////////////////////////////// #region Protected Methods /// <summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | #region Private Data /// <summary> /// The <see cref="IEnumerable" /> instance containing the backing data /// for the virtual table. /// </summary> private IEnumerable enumerable; /////////////////////////////////////////////////////////////////////// /// <summary> /// Non-zero if different object instances with the same value should /// generate different row identifiers, where applicable. This has no /// effect on the .NET Compact Framework. /// </summary> private bool objectIdentity; #endregion /////////////////////////////////////////////////////////////////////// #region Public Constructors /// <summary> /// Constructs an instance of this class. /// </summary> /// <param name="name"> /// The name of the module. This parameter cannot be null. /// </param> /// <param name="enumerable"> /// The <see cref="IEnumerable" /> instance to expose as a virtual /// table. This parameter cannot be null. /// </param> public SQLiteModuleEnumerable( string name, IEnumerable enumerable ) : this(name, enumerable, false) { // do nothing. } /////////////////////////////////////////////////////////////////////// /// <summary> /// Constructs an instance of this class. /// </summary> /// <param name="name"> /// The name of the module. This parameter cannot be null. /// </param> /// <param name="enumerable"> /// The <see cref="IEnumerable" /> instance to expose as a virtual /// table. This parameter cannot be null. /// </param> /// <param name="objectIdentity"> /// Non-zero if different object instances with the same value should /// generate different row identifiers, where applicable. This /// parameter has no effect on the .NET Compact Framework. /// </param> public SQLiteModuleEnumerable( string name, IEnumerable enumerable, bool objectIdentity ) : base(name) { if (enumerable == null) throw new ArgumentNullException("enumerable"); this.enumerable = enumerable; this.objectIdentity = objectIdentity; } #endregion /////////////////////////////////////////////////////////////////////// #region Protected Methods /// <summary> |
︙ | ︙ | |||
481 482 483 484 485 486 487 | /// The unique row identifier or zero upon failure. /// </returns> protected virtual long GetRowIdFromObject( SQLiteVirtualTableCursor cursor, object value ) { | < < < | < | | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | /// The unique row identifier or zero upon failure. /// </returns> protected virtual long GetRowIdFromObject( SQLiteVirtualTableCursor cursor, object value ) { int rowIndex = (cursor != null) ? cursor.GetRowIndex() : 0; int hashCode = SQLiteMarshal.GetHashCode(value, objectIdentity); return MakeRowId(rowIndex, hashCode); } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteManagedModule Members /// <summary> |
︙ | ︙ |