Example #1
0
        public void SetStringDictionaryData(string key, Dictionary <string, string> values)
        {
            try
            {
                key = key.Trim();
                JsonDictionaryConfig jsonConfig = null;
                string stringDictionaryJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("Dictionary"), "");
                if (stringDictionaryJsonData != "")
                {
                    jsonConfig = JsonMapper.ToObject <JsonDictionaryConfig>(stringDictionaryJsonData);
                }
                else
                {
                    jsonConfig = new JsonDictionaryConfig();
                }

                CheckDictionaryNull(jsonConfig);
                foreach (KeyValuePair <string, string> item in values)
                {
                    jsonConfig.SetDictionaryStringData(item.Key, item.Value);
                }

                string json_data = JsonMapper.ToJson(jsonConfig);
                PlayerPrefs.SetString(key + MD5Helper.HashString("Dictionary"), json_data);
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError(ex.ToString());
            }
        }
Example #2
0
 private void CheckDictionaryNull(JsonDictionaryConfig jsonConfig)
 {
     if (jsonConfig.DictionaryStringData == null)
     {
         jsonConfig.DictionaryStringData = new Dictionary <string, string>();
     }
 }
Example #3
0
        public Dictionary <string, string> GetStringDictionaryData(string key)
        {
            key = key.Trim();
            string stringDictionaryJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("Dictionary"), "");

            if (stringDictionaryJsonData != "")
            {
                JsonDictionaryConfig jsondata = JsonMapper.ToObject <JsonDictionaryConfig>(stringDictionaryJsonData);
                return(jsondata.GetDictionaryStringData());
            }
            return(new Dictionary <string, string>());
        }
Example #4
0
        public void RemoveStringDictionaryData(string key, string DicKey)
        {
            key = key.Trim();
            string stringDictionaryJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("Dictionary"), "");

            if (stringDictionaryJsonData != "")
            {
                JsonDictionaryConfig jsondata = JsonMapper.ToObject <JsonDictionaryConfig>(stringDictionaryJsonData);
                jsondata.RemoveData(DicKey);
                string json_data = JsonMapper.ToJson(jsondata);
                PlayerPrefs.SetString(key + MD5Helper.HashString("Dictionary"), json_data);
            }
        }