protected UnsafeNativeMethods.xSessionFilter GetDelegate(SessionTableFilterCallback tableFilterCallback, object clientData)
 {
     if (tableFilterCallback == null)
     {
         return(null);
     }
     return((IntPtr context, IntPtr pTblName) => {
         int num;
         try
         {
             string str = SQLiteString.StringFromUtf8IntPtr(pTblName);
             num = (tableFilterCallback(clientData, str) ? 1 : 0);
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             try
             {
                 if (HelperMethods.LogCallbackExceptions(base.GetFlags()))
                 {
                     SQLiteLog.LogMessage(-2146233088, HelperMethods.StringFormat(CultureInfo.CurrentCulture, "Caught exception in \"{0}\" method: {1}", new object[] { "xSessionFilter", exception }));
                 }
             }
             catch
             {
             }
             return 0;
         }
         return num;
     });
 }
예제 #2
0
        private int Filter(IntPtr context, IntPtr pTblName)
        {
            int num;

            try
            {
                num = (this.tableFilterCallback(this.tableFilterClientData, SQLiteString.StringFromUtf8IntPtr(pTblName)) ? 1 : 0);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                try
                {
                    if (HelperMethods.LogCallbackExceptions(base.GetFlags()))
                    {
                        CultureInfo currentCulture = CultureInfo.CurrentCulture;
                        object[]    objArray       = new object[] { "xSessionFilter", exception };
                        SQLiteLog.LogMessage(-2146233088, HelperMethods.StringFormat(currentCulture, "Caught exception in \"{0}\" method: {1}", objArray));
                    }
                }
                catch
                {
                }
                return(0);
            }
            return(num);
        }
예제 #3
0
        public static string[] StringArrayFromUtf8SizeAndIntPtr(int argc, IntPtr argv)
        {
            string str;

            if (argc < 0)
            {
                return(null);
            }
            if (argv == IntPtr.Zero)
            {
                return(null);
            }
            string[] strArrays = new string[argc];
            int      num       = 0;
            int      size      = 0;

            while (num < (int)strArrays.Length)
            {
                IntPtr   intPtr     = SQLiteMarshal.ReadIntPtr(argv, size);
                string[] strArrays1 = strArrays;
                int      num1       = num;
                if (intPtr != IntPtr.Zero)
                {
                    str = SQLiteString.StringFromUtf8IntPtr(intPtr);
                }
                else
                {
                    str = null;
                }
                strArrays1[num1] = str;
                num++;
                size += IntPtr.Size;
            }
            return(strArrays);
        }
예제 #4
0
        public string GetString()
        {
            if (this.pValue == IntPtr.Zero)
            {
                return(null);
            }
            int    num    = 0;
            IntPtr intPtr = UnsafeNativeMethods.sqlite3_value_text_interop(this.pValue, ref num);

            return(SQLiteString.StringFromUtf8IntPtr(intPtr, num));
        }
예제 #5
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;
                }
            }
        }
예제 #6
0
 private void PopulateOperationMetadata()
 {
     if (this.tableName == null || !this.numberOfColumns.HasValue || !this.operationCode.HasValue || !this.indirect.HasValue)
     {
         this.CheckIterator();
         IntPtr zero = IntPtr.Zero;
         SQLiteAuthorizerActionCode sQLiteAuthorizerActionCode = SQLiteAuthorizerActionCode.None;
         int             num             = 0;
         int             num1            = 0;
         SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_op(this.iterator.GetIntPtr(), ref zero, ref num1, ref sQLiteAuthorizerActionCode, ref num);
         if (sQLiteErrorCode != SQLiteErrorCode.Ok)
         {
             throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_op");
         }
         this.tableName       = SQLiteString.StringFromUtf8IntPtr(zero);
         this.numberOfColumns = new int?(num1);
         this.operationCode   = new SQLiteAuthorizerActionCode?(sQLiteAuthorizerActionCode);
         this.indirect        = new bool?(num != 0);
     }
 }
예제 #7
0
 public static string StringFromUtf8IntPtr(IntPtr pValue)
 {
     return(SQLiteString.StringFromUtf8IntPtr(pValue, SQLiteString.ProbeForUtf8ByteLength(pValue, SQLiteString.ThirtyBits)));
 }
예제 #8
0
        internal static void FromIntPtr(IntPtr pIndex, bool includeOutput, ref SQLiteIndex index)
        {
            if (pIndex == IntPtr.Zero)
            {
                return;
            }
            int num  = 0;
            int num1 = SQLiteMarshal.ReadInt32(pIndex, num);

            num = SQLiteMarshal.NextOffsetOf(num, 4, IntPtr.Size);
            IntPtr intPtr = SQLiteMarshal.ReadIntPtr(pIndex, num);

            num = SQLiteMarshal.NextOffsetOf(num, IntPtr.Size, 4);
            int num2 = SQLiteMarshal.ReadInt32(pIndex, num);

            num = SQLiteMarshal.NextOffsetOf(num, 4, IntPtr.Size);
            IntPtr intPtr1 = SQLiteMarshal.ReadIntPtr(pIndex, num);
            IntPtr zero    = IntPtr.Zero;

            if (includeOutput)
            {
                num  = SQLiteMarshal.NextOffsetOf(num, IntPtr.Size, IntPtr.Size);
                zero = SQLiteMarshal.ReadIntPtr(pIndex, num);
            }
            index = new SQLiteIndex(num1, num2);
            SQLiteIndexInputs inputs = index.Inputs;

            if (inputs == null)
            {
                return;
            }
            SQLiteIndexConstraint[] constraints = inputs.Constraints;
            if (constraints == null)
            {
                return;
            }
            SQLiteIndexOrderBy[] orderBys = inputs.OrderBys;
            if (orderBys == null)
            {
                return;
            }
            Type type = typeof(UnsafeNativeMethods.sqlite3_index_constraint);
            int  num3 = Marshal.SizeOf(type);

            for (int i = 0; i < num1; i++)
            {
                IntPtr intPtr2 = SQLiteMarshal.IntPtrForOffset(intPtr, i * num3);
                UnsafeNativeMethods.sqlite3_index_constraint structure = (UnsafeNativeMethods.sqlite3_index_constraint)Marshal.PtrToStructure(intPtr2, type);
                constraints[i] = new SQLiteIndexConstraint(structure);
            }
            Type type1 = typeof(UnsafeNativeMethods.sqlite3_index_orderby);
            int  num4  = Marshal.SizeOf(type1);

            for (int j = 0; j < num2; j++)
            {
                IntPtr intPtr3 = SQLiteMarshal.IntPtrForOffset(intPtr1, j * num4);
                UnsafeNativeMethods.sqlite3_index_orderby sqlite3IndexOrderby = (UnsafeNativeMethods.sqlite3_index_orderby)Marshal.PtrToStructure(intPtr3, type1);
                orderBys[j] = new SQLiteIndexOrderBy(sqlite3IndexOrderby);
            }
            if (includeOutput)
            {
                SQLiteIndexOutputs outputs = index.Outputs;
                if (outputs == null)
                {
                    return;
                }
                SQLiteIndexConstraintUsage[] constraintUsages = outputs.ConstraintUsages;
                if (constraintUsages == null)
                {
                    return;
                }
                Type type2 = typeof(UnsafeNativeMethods.sqlite3_index_constraint_usage);
                int  num5  = Marshal.SizeOf(type2);
                for (int k = 0; k < num1; k++)
                {
                    IntPtr intPtr4 = SQLiteMarshal.IntPtrForOffset(zero, k * num5);
                    UnsafeNativeMethods.sqlite3_index_constraint_usage sqlite3IndexConstraintUsage = (UnsafeNativeMethods.sqlite3_index_constraint_usage)Marshal.PtrToStructure(intPtr4, type2);
                    constraintUsages[k] = new SQLiteIndexConstraintUsage(sqlite3IndexConstraintUsage);
                }
                num = SQLiteMarshal.NextOffsetOf(num, IntPtr.Size, 4);
                outputs.IndexNumber = SQLiteMarshal.ReadInt32(pIndex, num);
                num = SQLiteMarshal.NextOffsetOf(num, 4, IntPtr.Size);
                outputs.IndexString = SQLiteString.StringFromUtf8IntPtr(SQLiteMarshal.ReadIntPtr(pIndex, num));
                num = SQLiteMarshal.NextOffsetOf(num, IntPtr.Size, 4);
                outputs.NeedToFreeIndexString = SQLiteMarshal.ReadInt32(pIndex, num);
                num = SQLiteMarshal.NextOffsetOf(num, 4, 4);
                outputs.OrderByConsumed = SQLiteMarshal.ReadInt32(pIndex, num);
                num = SQLiteMarshal.NextOffsetOf(num, 4, 8);
                outputs.EstimatedCost = new double?(SQLiteMarshal.ReadDouble(pIndex, num));
                num = SQLiteMarshal.NextOffsetOf(num, 8, 8);
                if (outputs.CanUseEstimatedRows())
                {
                    outputs.EstimatedRows = new long?(SQLiteMarshal.ReadInt64(pIndex, num));
                }
                num = SQLiteMarshal.NextOffsetOf(num, 8, 4);
                if (outputs.CanUseIndexFlags())
                {
                    outputs.IndexFlags = new SQLiteIndexFlags?((SQLiteIndexFlags)SQLiteMarshal.ReadInt32(pIndex, num));
                }
                num = SQLiteMarshal.NextOffsetOf(num, 4, 8);
                if (outputs.CanUseColumnsUsed())
                {
                    outputs.ColumnsUsed = new long?(SQLiteMarshal.ReadInt64(pIndex, num));
                }
            }
        }