protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { foreach (KeyValuePair <IntPtr, SQLiteFunction.AggregateData> keyValuePair in this._contextDataList) { IDisposable value = keyValuePair.Value._data as IDisposable; if (value == null) { continue; } value.Dispose(); } this._contextDataList.Clear(); this._contextDataList = null; this._flags = SQLiteConnectionFlags.None; this._InvokeFunc = null; this._StepFunc = null; this._FinalFunc = null; this._CompareFunc = null; this._base = null; } this.disposed = true; } }
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { //int n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, // funcstep, funcfinal); //if (n == 0) //{ // n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, // funcstep, funcfinal); //} //if (n > 0) //{ // throw new SqliteException(n, SQLiteLastError()); //} throw new NotImplementedException(); }
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int n; #if MONOTOUCH var data = new FunctionData(); data.Func = func; data.FuncStep = funcstep; data.FuncFinal = funcfinal; SQLiteCallback func_callback = func == null ? null : new SQLiteCallback(scalar_callback); SQLiteCallback funcstep_callback = funcstep == null ? null : new SQLiteCallback(step_callback); SQLiteFinalCallback funcfinal_callback = funcfinal == null ? null : new SQLiteFinalCallback(final_callback); IntPtr user_data; user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data)); n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 4, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback); if (n == 0) { // sqlite3_create_function_v2 will call 'destroy_callback' if it fails, so we need to recreate the gchandle here. user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data)); n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 1, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback); } #elif !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == 0) { n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); } #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == 0) { n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); } #endif if (n > 0) { throw new SqliteException(n, SQLiteLastError()); } }
protected virtual void Dispose(bool disposing) { if (disposing) { foreach (KeyValuePair <long, AggregateData> pair in this._contextDataList) { IDisposable disposable = pair.Value._data as IDisposable; if (disposable != null) { disposable.Dispose(); } } this._contextDataList.Clear(); this._InvokeFunc = null; this._StepFunc = null; this._FinalFunc = null; this._CompareFunc = null; this._base = null; this._contextDataList = null; } }
/////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Placeholder for a user-defined disposal routine /// </summary> /// <param name="disposing">True if the object is being disposed explicitly</param> protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// IDisposable disp; foreach (KeyValuePair <IntPtr, AggregateData> kv in _contextDataList) { disp = kv.Value._data as IDisposable; if (disp != null) { disp.Dispose(); } } _contextDataList.Clear(); _contextDataList = null; _flags = SQLiteConnectionFlags.None; _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } }
/// <summary> /// Placeholder for a user-defined disposal routine /// </summary> /// <param name="disposing">True if the object is being disposed explicitly</param> protected virtual void Dispose(bool disposing) { if (disposing) { IDisposable disp; foreach (KeyValuePair <long, AggregateData> kv in _contextDataList) { disp = kv.Value._data as IDisposable; if (disp != null) { disp.Dispose(); } } _contextDataList.Clear(); _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; _contextDataList = null; } }
internal static extern int sqlite3_create_function(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal);
internal static extern int sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq);
internal override SQLiteErrorCode CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal, bool canThrow) { SQLiteErrorCode n; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == SQLiteErrorCode.Ok) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == SQLiteErrorCode.Ok) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); #endif if (canThrow && (n != SQLiteErrorCode.Ok)) throw new SQLiteException(n, GetLastError()); return n; }
/// <summary> /// Placeholder for a user-defined disposal routine /// </summary> /// <param name="disposing">True if the object is being disposed explicitly</param> protected virtual void Dispose(bool disposing) { if (disposing) { IDisposable disp; foreach (KeyValuePair<long, AggregateData> kv in _contextDataList) { disp = kv.Value._data as IDisposable; if (disp != null) disp.Dispose(); } _contextDataList.Clear(); _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; _contextDataList = null; } }
internal abstract void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal);
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int n; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); #endif if (n > 0) throw new SqliteException(n, SQLiteLastError()); }
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int n; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == 0) { n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); } #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == 0) { n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); } #endif if (n > 0) { throw new SqliteException(n, SQLiteLastError()); } }
internal abstract SQLiteErrorCode CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal, bool @throw);
internal static extern int sqlite3_create_function_v2(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, SQLiteFinalCallback fdestroy);
/////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Placeholder for a user-defined disposal routine /// </summary> /// <param name="disposing">True if the object is being disposed explicitly</param> protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// IDisposable disp; foreach (KeyValuePair<IntPtr, AggregateData> kv in _contextDataList) { disp = kv.Value._data as IDisposable; if (disp != null) disp.Dispose(); } _contextDataList.Clear(); _contextDataList = null; _flags = SQLiteConnectionFlags.None; _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } }
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int errorCode = UnsafeNativeMethods.sqlite3_create_function_interop((IntPtr)this._sql, SQLiteConvert.ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, needCollSeq ? 1 : 0); if (errorCode == 0) { errorCode = UnsafeNativeMethods.sqlite3_create_function_interop((IntPtr)this._sql, SQLiteConvert.ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, needCollSeq ? 1 : 0); } if (errorCode > 0) { throw new SQLiteException(errorCode, this.SQLiteLastError()); } }
internal static void BindFunction(SQLiteBase sqliteBase, SQLiteFunctionAttribute functionAttribute, SQLiteFunction function, SQLiteConnectionFlags flags) { SQLiteCallback sQLiteCallback; SQLiteCallback sQLiteCallback1; SQLiteFinalCallback sQLiteFinalCallback; SQLiteCollation sQLiteCollation; SQLiteCollation sQLiteCollation1; if (sqliteBase == null) { throw new ArgumentNullException("sqliteBase"); } if (functionAttribute == null) { throw new ArgumentNullException("functionAttribute"); } if (function == null) { throw new ArgumentNullException("function"); } FunctionType funcType = functionAttribute.FuncType; function._base = sqliteBase; function._flags = flags; SQLiteFunction sQLiteFunction = function; if (funcType == FunctionType.Scalar) { sQLiteCallback = new SQLiteCallback(function.ScalarCallback); } else { sQLiteCallback = null; } sQLiteFunction._InvokeFunc = sQLiteCallback; SQLiteFunction sQLiteFunction1 = function; if (funcType == FunctionType.Aggregate) { sQLiteCallback1 = new SQLiteCallback(function.StepCallback); } else { sQLiteCallback1 = null; } sQLiteFunction1._StepFunc = sQLiteCallback1; SQLiteFunction sQLiteFunction2 = function; if (funcType == FunctionType.Aggregate) { sQLiteFinalCallback = new SQLiteFinalCallback(function.FinalCallback); } else { sQLiteFinalCallback = null; } sQLiteFunction2._FinalFunc = sQLiteFinalCallback; SQLiteFunction sQLiteFunction3 = function; if (funcType == FunctionType.Collation) { sQLiteCollation = new SQLiteCollation(function.CompareCallback); } else { sQLiteCollation = null; } sQLiteFunction3._CompareFunc = sQLiteCollation; SQLiteFunction sQLiteFunction4 = function; if (funcType == FunctionType.Collation) { sQLiteCollation1 = new SQLiteCollation(function.CompareCallback16); } else { sQLiteCollation1 = null; } sQLiteFunction4._CompareFunc16 = sQLiteCollation1; string name = functionAttribute.Name; if (funcType == FunctionType.Collation) { sqliteBase.CreateCollation(name, function._CompareFunc, function._CompareFunc16, true); return; } bool flag = function is SQLiteFunctionEx; sqliteBase.CreateFunction(name, functionAttribute.Arguments, flag, function._InvokeFunc, function._StepFunc, function._FinalFunc, true); }
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int n; #if MONOTOUCH var data = new FunctionData(); data.Func = func; data.FuncStep = funcstep; data.FuncFinal = funcfinal; SQLiteCallback func_callback = func == null ? null : new SQLiteCallback(scalar_callback); SQLiteCallback funcstep_callback = funcstep == null ? null : new SQLiteCallback(step_callback); SQLiteFinalCallback funcfinal_callback = funcfinal == null ? null : new SQLiteFinalCallback(final_callback); IntPtr user_data; user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data)); n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 4, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback); if (n == 0) { // sqlite3_create_function_v2 will call 'destroy_callback' if it fails, so we need to recreate the gchandle here. user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data)); n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 1, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback); } #elif !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); #endif if (n > 0) throw new SqliteException(n, SQLiteLastError()); }
internal static extern SQLiteErrorCode sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq);