コード例 #1
0
        private static string GetDefaultTypeName(SQLiteConnection connection)
        {
            if (((connection != null ? connection.Flags : SQLiteConnectionFlags.None) & SQLiteConnectionFlags.NoConvertSettings) == SQLiteConnectionFlags.NoConvertSettings)
            {
                return(SQLiteConvert.FallbackDefaultTypeName);
            }
            string str          = "Use_SQLiteConvert_DefaultTypeName";
            object settingValue = null;
            string str1         = null;

            if (connection == null || !connection.TryGetCachedSetting(str, str1, out settingValue))
            {
                try
                {
                    settingValue = UnsafeNativeMethods.GetSettingValue(str, str1) ?? SQLiteConvert.FallbackDefaultTypeName;
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.SetCachedSetting(str, settingValue);
                    }
                }
            }
            return(SQLiteConvert.SettingValueToString(settingValue));
        }
コード例 #2
0
        private static DbType GetDefaultDbType(SQLiteConnection connection)
        {
            DbType dbType;

            if (((connection != null ? connection.Flags : SQLiteConnectionFlags.None) & SQLiteConnectionFlags.NoConvertSettings) == SQLiteConnectionFlags.NoConvertSettings)
            {
                return(DbType.Object);
            }
            bool   flag         = false;
            string str          = "Use_SQLiteConvert_DefaultDbType";
            object settingValue = null;
            string str1         = null;

            if (connection == null || !connection.TryGetCachedSetting(str, str1, out settingValue))
            {
                settingValue = UnsafeNativeMethods.GetSettingValue(str, str1);
                if (settingValue == null)
                {
                    settingValue = DbType.Object;
                }
            }
            else
            {
                flag = true;
            }
            try
            {
                if (settingValue as DbType? == DbType.AnsiString)
                {
                    settingValue = SQLiteConnection.TryParseEnum(typeof(DbType), SQLiteConvert.SettingValueToString(settingValue), true);
                    if (settingValue as DbType? == DbType.AnsiString)
                    {
                        settingValue = DbType.Object;
                    }
                }
                dbType = (DbType)settingValue;
            }
            finally
            {
                if (!flag && connection != null)
                {
                    connection.SetCachedSetting(str, settingValue);
                }
            }
            return(dbType);
        }