/// <summary> /// Gets value of object in dictionary and deserializes it to specified type /// </summary> /// <typeparam name="T">Type of object to deserialize from</typeparam> /// <param name="key">Key</param> /// <returns></returns> public static T Get <T>(string key) where T : IConvertible { if (provider == null) { provider = QuranApp.NativeProvider.SettingsProvider; } if (cache.ContainsKey(key)) { try { return((T)cache[key]); } catch { return(GetDefaultValue <T>(key)); } } object value = null; if (provider.Contains(key)) { try { value = JsonConvert.DeserializeObject <T>(provider[key].ToString()); } catch { //Ignore } } if (value == null) { value = GetDefaultValue <T>(key); } try { cache[key] = value; return((T)value); } catch { cache[key] = GetDefaultValue <T>(key); return(GetDefaultValue <T>(key)); } }
public void Contain() { _settings.Contains(_property).Should().BeTrue(); }