public int CreateScalarFunction(IDbHandle dbHandle, IScalarFunction sqliteFunction) { var internalDbHandle = (DbHandle)dbHandle; FuncCallbackExecutor funcCallbackExecutor = null; if (_useWinSqlite) { funcCallbackExecutor = new FuncCallbackExecutor( sqliteFunction, WinSQLite3.GetAnsiString, WinSQLite3.sqlite3_result_int ); var func = new WinSQLite3.FuncCallback(funcCallbackExecutor.Execute); _allocatedGCHandles.Add(GCHandle.Alloc(func)); return(WinSQLite3.sqlite3_create_function( internalDbHandle.InternalDbHandle, Encoding.UTF8.GetBytes(sqliteFunction.Name), sqliteFunction.ValueGetters.Length, SQLiteEncodings.SQLITE_UTF8, IntPtr.Zero, func, null, null)); } else { funcCallbackExecutor = new FuncCallbackExecutor( sqliteFunction, SQLite3.GetAnsiString, SQLite3.sqlite3_result_int ); var func = new SQLite3.FuncCallback(funcCallbackExecutor.Execute); _allocatedGCHandles.Add(GCHandle.Alloc(func)); return(SQLite3.sqlite3_create_function( internalDbHandle.InternalDbHandle, Encoding.UTF8.GetBytes(sqliteFunction.Name), sqliteFunction.ValueGetters.Length, SQLiteEncodings.SQLITE_UTF8, IntPtr.Zero, func, null, null)); } }
public int CreateScalarFunction(IDbHandle db, IScalarFunction sqliteFunction) { var internalDbHandle = (DbHandle)db; var funcCallbackExecutor = new FuncCallbackExecutor( sqliteFunction, SQLiteApiGenericInternal.GetAnsiString, SQLiteApiGenericInternal.sqlite3_result_int ); var func = new SQLiteApiGenericInternal.FuncCallback(funcCallbackExecutor.Execute); _allocatedGCHandles.Add(GCHandle.Alloc(func)); return(SQLiteApiGenericInternal.sqlite3_create_function( internalDbHandle.DbPtr, Encoding.UTF8.GetBytes(sqliteFunction.Name), sqliteFunction.ValueGetters.Length, SQLiteEncodings.SQLITE_UTF8, IntPtr.Zero, func, null, null)); }