Esempio n. 1
0
        protected void SaveCache(string cacheKey, bool clearCache)
        {
            if (m_unencryptedKeys == null)
            {
                return;
            }
            IDictionary <string, object> dictionary  = new Dictionary <string, object>();
            IDictionary <string, object> dictionary2 = new Dictionary <string, object>();
            IDictionary <string, object> dictionary3 = new Dictionary <string, object>();
            IDictionary <string, object> dictionary4 = new Dictionary <string, object>();

            foreach (string key in m_unencryptedKeys.Keys)
            {
                try
                {
                    if (m_unencryptedKeys[key] == EncryptedPlayerPrefsBase.s_floatType)
                    {
                        dictionary2[key] = PlayerPrefs.GetFloat(key);
                    }
                    else if (m_unencryptedKeys[key] == EncryptedPlayerPrefsBase.s_intType)
                    {
                        dictionary3[key] = PlayerPrefs.GetInt(key);
                    }
                    else if (m_unencryptedKeys[key] == EncryptedPlayerPrefsBase.s_stringType)
                    {
                        dictionary4[key] = PlayerPrefs.GetString(key);
                    }
                }
                catch (Exception)
                {
                }
            }
            if (dictionary2.Count > 0)
            {
                dictionary["float"] = dictionary2;
            }
            if (dictionary3.Count > 0)
            {
                dictionary["int"] = dictionary3;
            }
            if (dictionary4.Count > 0)
            {
                dictionary["string"] = dictionary4;
            }
            try
            {
                string text = LPFJson.serialize(dictionary);
                SaveValueEncrypted(cacheKey, (text == null) ? "" : text);
                if (clearCache)
                {
                    DeleteAll(wipeInternalKeys: false, wipeCache: false);
                    m_isLoaded = false;
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        protected void LoadCache(string cacheKey)
        {
            if (m_isLoaded)
            {
                return;
            }
            m_unencryptedKeys = new Dictionary <string, Type>();
            string decryptedValue = GetDecryptedValue(cacheKey);

            if (decryptedValue != null && decryptedValue.Length > 0)
            {
                try
                {
                    IDictionary <string, object> dictionary = LPFJson.parse(decryptedValue) as IDictionary <string, object>;
                    if (dictionary != null)
                    {
                        if (dictionary.ContainsKey("float"))
                        {
                            IDictionary <string, object> dictionary2 = dictionary["float"] as IDictionary <string, object>;
                            foreach (string key in dictionary2.Keys)
                            {
                                try
                                {
                                    float value = Convert.ToSingle(dictionary2[key]);
                                    PlayerPrefs.SetFloat(key, value);
                                    m_unencryptedKeys[key] = EncryptedPlayerPrefsBase.s_floatType;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                        if (dictionary.ContainsKey("int"))
                        {
                            IDictionary <string, object> dictionary3 = dictionary["int"] as IDictionary <string, object>;
                            foreach (string key2 in dictionary3.Keys)
                            {
                                try
                                {
                                    int value2 = Convert.ToInt32(dictionary3[key2]);
                                    PlayerPrefs.SetInt(key2, value2);
                                    m_unencryptedKeys[key2] = EncryptedPlayerPrefsBase.s_intType;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                        if (dictionary.ContainsKey("string"))
                        {
                            IDictionary <string, object> dictionary4 = dictionary["string"] as IDictionary <string, object>;
                            foreach (string key3 in dictionary4.Keys)
                            {
                                try
                                {
                                    string value3 = dictionary4[key3].ToString();
                                    PlayerPrefs.SetString(key3, value3);
                                    m_unencryptedKeys[key3] = EncryptedPlayerPrefsBase.s_stringType;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            m_isLoaded = true;
        }