public void SetError(string value)
 {
     if (this.pContext == IntPtr.Zero)
     {
         throw new InvalidOperationException();
     }
     byte[] utf8BytesFromString = SQLiteString.GetUtf8BytesFromString(value);
     if (utf8BytesFromString == null)
     {
         throw new ArgumentNullException("value");
     }
     UnsafeNativeMethods.sqlite3_result_error(this.pContext, utf8BytesFromString, (int)utf8BytesFromString.Length);
 }
        public static IntPtr Utf8IntPtrFromString(string value, ref int length)
        {
            if (value == null)
            {
                return(IntPtr.Zero);
            }
            IntPtr zero = IntPtr.Zero;

            byte[] utf8BytesFromString = SQLiteString.GetUtf8BytesFromString(value);
            if (utf8BytesFromString == null)
            {
                return(IntPtr.Zero);
            }
            length = (int)utf8BytesFromString.Length;
            zero   = SQLiteMemory.Allocate(length + 1);
            if (zero == IntPtr.Zero)
            {
                return(IntPtr.Zero);
            }
            Marshal.Copy(utf8BytesFromString, 0, zero, length);
            Marshal.WriteByte(zero, length, 0);
            return(zero);
        }
Esempio n. 3
0
        public void AttachTable(string name)
        {
            this.CheckDisposed();
            this.CheckHandle();
            SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3session_attach(this.session, SQLiteString.GetUtf8BytesFromString(name));

            if (sQLiteErrorCode != SQLiteErrorCode.Ok)
            {
                throw new SQLiteException(sQLiteErrorCode, "sqlite3session_attach");
            }
        }
Esempio n. 4
0
        public void LoadDifferencesFromTable(string fromDatabaseName, string tableName)
        {
            this.CheckDisposed();
            this.CheckHandle();
            if (fromDatabaseName == null)
            {
                throw new ArgumentNullException("fromDatabaseName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }
            IntPtr zero = IntPtr.Zero;

            try
            {
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3session_diff(this.session, SQLiteString.GetUtf8BytesFromString(fromDatabaseName), SQLiteString.GetUtf8BytesFromString(tableName), ref zero);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    string str = null;
                    if (zero != IntPtr.Zero)
                    {
                        str = SQLiteString.StringFromUtf8IntPtr(zero);
                        if (!string.IsNullOrEmpty(str))
                        {
                            CultureInfo currentCulture = CultureInfo.CurrentCulture;
                            object[]    objArray       = new object[] { str };
                            str = HelperMethods.StringFormat(currentCulture, ": {0}", objArray);
                        }
                    }
                    CultureInfo cultureInfo = CultureInfo.CurrentCulture;
                    object[]    objArray1   = new object[] { "sqlite3session_diff", str };
                    throw new SQLiteException(sQLiteErrorCode, HelperMethods.StringFormat(cultureInfo, "{0}{1}", objArray1));
                }
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    SQLiteMemory.Free(zero);
                    zero = IntPtr.Zero;
                }
            }
        }
Esempio n. 5
0
        private void InitializeHandle()
        {
            if (this.session != IntPtr.Zero)
            {
                return;
            }
            SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3session_create(base.GetIntPtr(), SQLiteString.GetUtf8BytesFromString(this.databaseName), ref this.session);

            if (sQLiteErrorCode != SQLiteErrorCode.Ok)
            {
                throw new SQLiteException(sQLiteErrorCode, "sqlite3session_create");
            }
        }