public override IEnumerator DoPut(string key, object value, BoolAction <Exception> action) { try { IList <string> keys = GetKeys(); if (value == null) { PlayerPrefs.DeleteKey(prefix + key); keys.Remove(key); } else { PlayerPrefs.SetString(prefix + key, value.ToString()); if (!keys.Contains(key)) { keys.Add(key); } } SetKeys(keys); PlayerPrefs.Save(); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoPutObjects(BoolAction <Exception> action, Action <float> progress, IStorableObject[] storableObjects) { try { progress(0); IList <string> keys = GetKeys(); foreach (IStorableObject storableObject in storableObjects) { string key = storableObject.GetStorableKey(), value = JSON.ToJson(storableObject.GetStorableObject()); PlayerPrefs.SetString(prefix + key, value); if (!keys.Contains(key)) { keys.Add(key); } } progress(0.95f); SetKeys(keys); PlayerPrefs.Save(); progress(1f); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoPutMultiple(IDictionary <string, object> keyValuePairs, BoolAction <Exception> action, Action <float> progess) { try { progess(0); IList <string> keys = GetKeys(); foreach (KeyValuePair <string, object> keyValuePair in keyValuePairs) { if (keyValuePair.Value == null) { PlayerPrefs.DeleteKey(prefix + keyValuePair.Key); keys.Remove(keyValuePair.Key); } else { PlayerPrefs.SetString(prefix + keyValuePair.Key, keyValuePair.Value.ToString()); if (!keys.Contains(keyValuePair.Key)) { keys.Add(keyValuePair.Key); } } } progess(0.95f); SetKeys(keys); PlayerPrefs.Save(); progess(1); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
protected virtual IEnumerator DoSetDataMultiple(IDictionary <string, object> keyValuePairs, MonoBehaviour context, BoolAction <Exception> action) { foreach (KeyValuePair <string, object> kv in keyValuePairs) { bool t1 = false; Exception t2 = null; Coroutine c; try { c = context.StartCoroutine(DoSetData(kv.Key, kv.Value, context, (s, e) => { t1 = s; t2 = e; })); } catch (Exception e) { action?.Invoke(false, e); yield break; } yield return(c); if (!t1) { action?.Invoke(false, t2); yield break; } } }
public override IEnumerator DoPut(string key, object value, BoolAction <Exception> action) { try { Map[key] = value; action?.Invoke(true, null); } catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoClear(BoolAction <Exception> action) { try { Map.Clear(); action?.Invoke(true, null); } catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoPutMultiple(IDictionary <string, object> keyValuePairs, BoolAction <Exception> action, Action <float> progess) { try { progess(0); foreach (KeyValuePair <string, object> kv in keyValuePairs) { Map[kv.Key] = kv.Value; } progess(1); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoPutObjects(BoolAction <Exception> action, Action <float> progress, IStorableObject[] storableObjects) { try { progress(0); foreach (IStorableObject storableObject in storableObjects) { Map[storableObject.GetStorableKey()] = storableObject.GetStorableObject(); } progress(1); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public void PutObjects(MonoBehaviour context, BoolAction <Exception> action, Action <float> progess, params IStorableObject[] storableObjects) { try { context.StartCoroutine(DoPutObjects(action, progess, storableObjects)); }catch (Exception e) { action?.Invoke(false, e); } }
public void Clear(MonoBehaviour context, BoolAction <Exception> action) { try { context.StartCoroutine(DoClear(action)); }catch (Exception e) { action?.Invoke(false, e); } }
public override IEnumerator DoClear(BoolAction <Exception> action) { try { IList <string> keys = GetKeys(); foreach (string key in keys) { PlayerPrefs.DeleteKey(prefix + key); } keys.Clear(); SetKeys(keys); PlayerPrefs.Save(); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public void Put(string key, MonoBehaviour context, object value, BoolAction <Exception> action) { try { context.StartCoroutine(DoPut(key, value, action)); } catch (Exception e) { action?.Invoke(false, e); } }
public void PutMultiple(IDictionary <string, object> keyValuePairs, MonoBehaviour context, BoolAction <Exception> action, Action <float> progess) { try { context.StartCoroutine(DoPutMultiple(keyValuePairs, action, progess)); } catch (Exception e) { action?.Invoke(false, e); } }
public override IEnumerator DoRestoreObjects(BoolAction <Exception> action, Action <float> progess, IStorableObject[] storableObjects) { try { progess(0); foreach (IStorableObject storableObject in storableObjects) { if (Map.ContainsKey(storableObject.GetStorableKey())) { storableObject.OnStorableObjectRestore(Map[storableObject.GetStorableKey()]); } } progess(1); action?.Invoke(true, null); } catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public override IEnumerator DoRestoreObjects(BoolAction <Exception> action, Action <float> progess, IStorableObject[] storableObjects) { try { progess(0); foreach (IStorableObject storableObject in storableObjects) { string json = PlayerPrefs.GetString(prefix + storableObject.GetStorableKey()); if (json == null) { continue; } storableObject.OnStorableObjectRestore(JSON.FromJson(json, storableObject.GetStorableObjectType())); } progess(1); action?.Invoke(true, null); } catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
public void RestoreObjects(MonoBehaviour context, BoolAction <Exception> action, Action <float> progess, params IStorableObject[] storableObjects) { if (action == null) { Debug.Log("Action is null!"); return; } try { context.StartCoroutine(DoRestoreObjects(action, progess, storableObjects)); } catch (Exception e) { action?.Invoke(false, e); } }
public void PutMultiple(string[] keys, object[] values, MonoBehaviour context, BoolAction <Exception> action, Action <float> progess) { try { int len = Math.Min(keys.Length, values.Length); Dictionary <string, object> map = new Dictionary <string, object>(); for (int i = 0; i < len; i++) { map[keys[i]] = values[i]; } PutMultiple(map, context, action, progess); } catch (Exception e) { action?.Invoke(false, e); } }
public bool TearDownSubclass() { return((_tearDownFunc != null) ? _tearDownFunc.Invoke() : false); }
public bool IsSubclassed() { return((_isSubclassedFunc != null) ? _isSubclassedFunc.Invoke() : false); }