예제 #1
0
        public int CreateScalarFunction(IDbHandle db, IScalarFunction sqliteFunction)
        {
            var internalDbHandle = (DbHandle)db;

            var funcCallbackExecutor = new FuncCallbackExecutor(
                sqliteFunction,
                SQLiteApiWin32Internal.GetAnsiString,
                SQLiteApiWin32Internal.sqlite3_result_int
                );

            var func = new SQLiteApiWin32Internal.FuncCallback(funcCallbackExecutor.Execute);

            _allocatedGCHandles.Add(GCHandle.Alloc(func));

            return(SQLiteApiWin32Internal.sqlite3_create_function(
                       internalDbHandle.DbPtr,
                       Encoding.UTF8.GetBytes(sqliteFunction.Name),
                       sqliteFunction.ValueGetters.Length,
                       SQLiteEncodings.SQLITE_UTF8,
                       IntPtr.Zero,
                       func,
                       null,
                       null));
        }