private string GetValue(string keyName, IDictionary <string, string> dictionary) { string value; if (dictionary.TryGetValue(keyName, out value)) { value = encryptor.Decode(value); } return(value); }
public override object GetObject(string key, Type type, object defaultValue) { if (!PlayerPrefs.HasKey(Key(key))) { return(defaultValue); } string str = PlayerPrefs.GetString(Key(key)); if (string.IsNullOrEmpty(str)) { return(defaultValue); } if (Encryptor != null) { byte[] data = Convert.FromBase64String(str); data = Encryptor.Decode(data); str = Encoding.UTF8.GetString(data); } return(Serializer.Deserialize(str, type)); }
/// <summary> /// </summary> protected override void Load() { try { var filename = GetFullFileName().ToString(); if (!File.Exists(filename)) { return; } var data = File.ReadAllBytes(filename); if (data == null || data.Length <= 0) { return; } if (encryptor != null) { data = encryptor.Decode(data); } dict.Clear(); using (MemoryStream stream = new MemoryStream(data)) { using (BinaryReader reader = new BinaryReader(stream)) { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var key = reader.ReadString(); var value = reader.ReadString(); dict.Add(key, value); } } } } catch (Exception e) { if (log.IsWarnEnabled) { log.WarnFormat("Load failed,{0}", e); } } }
/// <summary> /// /// </summary> protected override void Load() { try { string filename = GetFullFileName().ToString(); if (!File.Exists(filename)) { return; } byte[] data = File.ReadAllBytes(filename); if (data.Length <= 0) { return; } if (this.Encryptor != null) { data = Encryptor.Decode(data); } this.Dict.Clear(); using (MemoryStream stream = new MemoryStream(data)) { using (BinaryReader reader = new BinaryReader(stream)) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { string key = reader.ReadString(); string value = reader.ReadString(); this.Dict.Add(key, value); } } } } catch (Exception e) { Log.Warning($"Load failed >> {e}"); } }