コード例 #1
0
        public void Apply(SessionConflictCallback conflictCallback, SessionTableFilterCallback tableFilterCallback, object clientData)
        {
            this.CheckDisposed();
            SQLiteSessionHelpers.CheckRawData(this.rawData);
            if (conflictCallback == null)
            {
                throw new ArgumentNullException("conflictCallback");
            }
            UnsafeNativeMethods.xSessionFilter   @delegate         = base.GetDelegate(tableFilterCallback, clientData);
            UnsafeNativeMethods.xSessionConflict _xSessionConflict = base.GetDelegate(conflictCallback, clientData);
            IntPtr zero = IntPtr.Zero;

            try
            {
                int num = 0;
                zero = SQLiteBytes.ToIntPtr(this.rawData, ref num);
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_apply(base.GetIntPtr(), num, zero, @delegate, _xSessionConflict, IntPtr.Zero);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_apply");
                }
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero);
                    zero = IntPtr.Zero;
                }
            }
        }
コード例 #2
0
        public void AddChangeSet(byte[] rawData)
        {
            this.CheckDisposed();
            this.CheckHandle();
            SQLiteSessionHelpers.CheckRawData(rawData);
            IntPtr zero = IntPtr.Zero;

            try
            {
                int num = 0;
                zero = SQLiteBytes.ToIntPtr(rawData, ref num);
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changegroup_add(this.changeGroup, num, zero);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changegroup_add");
                }
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero);
                    zero = IntPtr.Zero;
                }
            }
        }
コード例 #3
0
        public ISQLiteChangeSet CombineWith(ISQLiteChangeSet changeSet)
        {
            ISQLiteChangeSet sQLiteMemoryChangeSets;

            this.CheckDisposed();
            SQLiteSessionHelpers.CheckRawData(this.rawData);
            SQLiteMemoryChangeSet sQLiteMemoryChangeSets1 = changeSet as SQLiteMemoryChangeSet;

            if (sQLiteMemoryChangeSets1 == null)
            {
                throw new ArgumentException("not a memory based change set", "changeSet");
            }
            SQLiteSessionHelpers.CheckRawData(sQLiteMemoryChangeSets1.rawData);
            IntPtr zero   = IntPtr.Zero;
            IntPtr intPtr = IntPtr.Zero;
            IntPtr zero1  = IntPtr.Zero;

            try
            {
                int num = 0;
                zero = SQLiteBytes.ToIntPtr(this.rawData, ref num);
                int num1 = 0;
                intPtr = SQLiteBytes.ToIntPtr(sQLiteMemoryChangeSets1.rawData, ref num1);
                int             num2            = 0;
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_concat(num, zero, num1, intPtr, ref num2, ref zero1);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_concat");
                }
                byte[] numArray = SQLiteBytes.FromIntPtr(zero1, num2);
                sQLiteMemoryChangeSets = new SQLiteMemoryChangeSet(numArray, base.GetHandle(), base.GetFlags());
            }
            finally
            {
                if (zero1 != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero1);
                    zero1 = IntPtr.Zero;
                }
                if (intPtr != IntPtr.Zero)
                {
                    SQLiteMemory.Free(intPtr);
                    intPtr = IntPtr.Zero;
                }
                if (zero != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero);
                    zero = IntPtr.Zero;
                }
            }
            return(sQLiteMemoryChangeSets);
        }
コード例 #4
0
        public static SQLiteMemoryChangeSetIterator Create(byte[] rawData)
        {
            SQLiteSessionHelpers.CheckRawData(rawData);
            SQLiteMemoryChangeSetIterator sQLiteMemoryChangeSetIterator = null;
            IntPtr zero   = IntPtr.Zero;
            IntPtr intPtr = IntPtr.Zero;

            try
            {
                int num = 0;
                zero = SQLiteBytes.ToIntPtr(rawData, ref num);
                if (zero == IntPtr.Zero)
                {
                    throw new SQLiteException(SQLiteErrorCode.NoMem, null);
                }
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_start(ref intPtr, num, zero);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_start");
                }
                sQLiteMemoryChangeSetIterator = new SQLiteMemoryChangeSetIterator(zero, intPtr, true);
            }
            finally
            {
                if (sQLiteMemoryChangeSetIterator == null)
                {
                    if (intPtr != IntPtr.Zero)
                    {
                        UnsafeNativeMethods.sqlite3changeset_finalize(intPtr);
                        intPtr = IntPtr.Zero;
                    }
                    if (zero != IntPtr.Zero)
                    {
                        SQLiteMemory.Free(zero);
                        zero = IntPtr.Zero;
                    }
                }
            }
            return(sQLiteMemoryChangeSetIterator);
        }
コード例 #5
0
        public ISQLiteChangeSet Invert()
        {
            ISQLiteChangeSet sQLiteMemoryChangeSets;

            this.CheckDisposed();
            SQLiteSessionHelpers.CheckRawData(this.rawData);
            IntPtr zero   = IntPtr.Zero;
            IntPtr intPtr = IntPtr.Zero;

            try
            {
                int num = 0;
                zero = SQLiteBytes.ToIntPtr(this.rawData, ref num);
                int             num1            = 0;
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_invert(num, zero, ref num1, ref intPtr);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_invert");
                }
                byte[] numArray = SQLiteBytes.FromIntPtr(intPtr, num1);
                sQLiteMemoryChangeSets = new SQLiteMemoryChangeSet(numArray, base.GetHandle(), base.GetFlags());
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    SQLiteMemory.Free(intPtr);
                    intPtr = IntPtr.Zero;
                }
                if (zero != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero);
                    zero = IntPtr.Zero;
                }
            }
            return(sQLiteMemoryChangeSets);
        }