コード例 #1
0
        internal collation_hook_info(delegate_collation func, object v)
        {
            _func      = func;
            _user_data = v;

            _h = GCHandle.Alloc(this);
        }
コード例 #2
0
 /// <summary>Create custom collation.</summary>
 /// <typeparam name="T">The type of the state object.</typeparam>
 /// <param name="name">Name of the collation.</param>
 /// <param name="state">State object passed to each invocation of the collation.</param>
 /// <param name="comparison">Method that compares two strings, using additional state.</param>
 public virtual void CreateCollation<T>(string name, T state, Func<T, string, string, int> comparison)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentNullException(nameof(name));
     if (this.State != ConnectionState.Open)
         throw new InvalidOperationException("RequiresOpenConnection"+((object)nameof(CreateCollation)));
     delegate_collation f = comparison != null ? (delegate_collation)((v, s1, s2) => comparison((T)v, s1, s2)) : (delegate_collation)null;
     SqliteException.ThrowExceptionForRC(raw.sqlite3_create_collation(this._db, name, (object)state, f), this._db);
 }
コード例 #3
0
 internal void free()
 {
     _func      = null;
     _user_data = null;
     _h.Free();
 }
コード例 #4
0
 int ISQLite3Provider.sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func)
 {
     throw new Exception(GRIPE);
 }
コード例 #5
0
ファイル: callbacks.cs プロジェクト: medicomp/SQLitePCL.raw
 public collation_hook_info(delegate_collation func, object v)
 {
     _func      = func;
     _user_data = v;
 }
コード例 #6
0
 static public int sqlite3_create_collation(sqlite3 db, string name, object v, delegate_collation f)
 {
     return(_imp.sqlite3_create_collation(db.ptr, name, v, f));
 }
コード例 #7
0
        int ISQLite3Provider.sqlite3_create_collation (IntPtr db, string name, object v, delegate_collation func)
        {
            var info = hooks.getOrCreateFor (db);
            if (info.collation.ContainsKey (name)) {
                collation_hook_info hi = info.collation [name];

                // TODO maybe turn off the hook here, for now
                hi.free ();

                info.collation.Remove (name);
            }

            // 1 is SQLITE_UTF8
            if (func != null) {
                collation_hook_info hi = new collation_hook_info (func, v);
                int rc = NativeMethods.sqlite3_create_collation (db, util.to_utf8 (name), 1, hi.ptr, collation_hook_bridge);
                if (rc == 0) {
                    info.collation [name] = hi;
                }
                return rc;
            } else {
                return NativeMethods.sqlite3_create_collation (db, util.to_utf8 (name), 1, IntPtr.Zero, null);
            }
        }
コード例 #8
0
ファイル: raw.cs プロジェクト: shiftkey/SQLitePCL.raw
 static public int sqlite3_create_collation(sqlite3 db, string name, object v, delegate_collation f)
 {
     return _imp.sqlite3_create_collation(db.ptr, name, v, f);
 }
コード例 #9
0
        public static void create_collation(this sqlite3 db, string name, object v, delegate_collation f)
        {
            int rc = raw.sqlite3_create_collation(db, name, v, f);

            check_ok(rc);
        }
コード例 #10
0
ファイル: util.cs プロジェクト: zgramana/SQLitePCL.raw
 internal void free()
 {
     _func = null;
     _user_data = null;
     _h.Free();
 }
コード例 #11
0
ファイル: util.cs プロジェクト: zgramana/SQLitePCL.raw
        internal collation_hook_info(delegate_collation func, object v)
        {
            _func = func;
            _user_data = v;

            _h = GCHandle.Alloc(this);
        }
コード例 #12
0
 public int sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func) => throw new NotImplementedException();
コード例 #13
0
        int ISQLite3Provider.sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func)
        {
            if (_collation_hooks.ContainsKey(name))
            {
                collation_hook_info hi = _collation_hooks[name];

                // TODO maybe turn off the hook here, for now
                hi.free();

                _collation_hooks.Remove(name);
            }

            GCHandle pinned = GCHandle.Alloc(util.to_utf8(name), GCHandleType.Pinned);
            IntPtr   ptr    = pinned.AddrOfPinnedObject();

            int rc;

            // 1 is SQLITE_UTF8
            if (func != null)
            {
                collation_hook_info hi = new collation_hook_info(func, v);
                rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, hi.ptr.ToInt64(), Marshal.GetFunctionPointerForDelegate(new callback_collation(collation_hook_bridge)).ToInt64());
                if (rc == 0)
                {
                    _collation_hooks[name] = hi;
                }
            }
            else
            {
                rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, IntPtr.Zero.ToInt64(), IntPtr.Zero.ToInt64());
            }

            pinned.Free();

            return(rc);
        }
コード例 #14
0
        int ISQLite3Provider.sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func)
        {
		var info = hooks.getOrCreateFor(db);
            if (info.collation.ContainsKey(name))
            {
                collation_hook_info hi = info.collation[name];

                // TODO maybe turn off the hook here, for now
                hi.free();

                info.collation.Remove(name);
            }

            GCHandle pinned = GCHandle.Alloc(util.to_utf8(name), GCHandleType.Pinned);
            IntPtr ptr = pinned.AddrOfPinnedObject();

            int rc;

            // 1 is SQLITE_UTF8
            if (func != null)
            {
                collation_hook_info hi = new collation_hook_info(func, v);
                rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, hi.ptr.ToInt64(), Marshal.GetFunctionPointerForDelegate(collation_hook_bridge).ToInt64());
                if (rc == 0)
                {
                    info.collation[name] = hi;
                }
            }
            else
            {
                rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, IntPtr.Zero.ToInt64(), IntPtr.Zero.ToInt64());
            }

            pinned.Free();

            return rc;
        }
コード例 #15
0
        int ISQLite3Provider.sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func)
        {
	    throw new Exception(GRIPE);
        }