Exemplo n.º 1
0
        public int CreateCollation(IDbHandle db, ICollation collation)
        {
            if (_useWinSqlite)
            {
                var internalDbHandle = (DbHandle)db;

                var compareCallbackExecutor = new CompareCallbackExecutor(
                    collation,
                    WinSQLite3.GetCompareCallbackStringBytes);

                var func = new WinSQLite3.CompareCallback(compareCallbackExecutor.Execute);

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

                return(WinSQLite3.sqlite3_create_collation(
                           internalDbHandle.InternalDbHandle,
                           Encoding.UTF8.GetBytes(collation.Name),
                           SQLiteEncodings.SQLITE_UTF8,
                           IntPtr.Zero,
                           func));
            }
            else
            {
                var internalDbHandle = (DbHandle)db;

                var compareCallbackExecutor = new CompareCallbackExecutor(
                    collation,
                    SQLite3.GetCompareCallbackStringBytes);

                var func = new SQLite3.CompareCallback(compareCallbackExecutor.Execute);

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

                return(SQLite3.sqlite3_create_collation(
                           internalDbHandle.InternalDbHandle,
                           Encoding.UTF8.GetBytes(collation.Name),
                           SQLiteEncodings.SQLITE_UTF8,
                           IntPtr.Zero,
                           func));
            }
        }