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
        public void SetStringListData(string key, List <string> values)
        {
            try
            {
                key = key.Trim();
                JsonListConfig jsonConfig         = null;
                string         stringListJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("list"), "");
                if (stringListJsonData != "")
                {
                    jsonConfig = JsonMapper.ToObject <JsonListConfig>(stringListJsonData);
                }
                else
                {
                    jsonConfig = new JsonListConfig();
                }

                CheckListNull(jsonConfig);
                for (int i = 0; i < values.Count; ++i)
                {
                    jsonConfig.SetListStringData(values[i].Trim());
                }
                string json_data = JsonMapper.ToJson(jsonConfig);
                PlayerPrefs.SetString(key + MD5Helper.HashString("list"), json_data);
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError(ex.ToString());
            }
        }
Example #3
0
        public void SetSelfDefineType <T>(string key, T jsonConfig)
        {
            key = key.Trim();
            string json_data = JsonMapper.ToJson(jsonConfig);

            PlayerPrefs.SetString(key + MD5Helper.HashString("self"), json_data);
        }
Example #4
0
        public T GetSelfDefineType <T>(string key)
        {
            key = key.Trim();
            string stringDictionaryJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("self"), "");

            if (stringDictionaryJsonData != "")
            {
                T jsonConfig = JsonMapper.ToObject <T>(stringDictionaryJsonData);
                return(jsonConfig);
            }
            return(default(T));
        }
Example #5
0
        public List <string> GetStringListData(string key)
        {
            key = key.Trim();
            string stringListJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("list"), "");

            if (stringListJsonData != "")
            {
                JsonListConfig jsondata = JsonMapper.ToObject <JsonListConfig>(stringListJsonData);
                return(jsondata.GetListStringData());
            }
            return(new List <string>());
        }
Example #6
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 #7
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);
            }
        }
Example #8
0
        public void RemoveStringListData(string key, string value)
        {
            key   = key.Trim();
            value = value.Trim();
            string stringListJsonData = PlayerPrefs.GetString(key + MD5Helper.HashString("list"), "");

            if (stringListJsonData != "")
            {
                JsonListConfig jsondata = JsonMapper.ToObject <JsonListConfig>(stringListJsonData);
                jsondata.RemoveData(value);
                string json_data = JsonMapper.ToJson(jsondata);
                PlayerPrefs.SetString(key + MD5Helper.HashString("list"), json_data);
            }
        }
Example #9
0
 public void RemoveSelfDefineTypeData(string key)
 {
     PlayerPrefs.DeleteKey(key.Trim() + MD5Helper.HashString("self"));
 }
Example #10
0
 public void RemoveStringListDataByKey(string key)
 {
     key = key.Trim();
     PlayerPrefs.DeleteKey(key + MD5Helper.HashString("list"));
 }