public bool GetRecordOnStart() { if (Preference.Contains("record_on_start")) { return(Preference.Get <bool>("record_on_start")); } return(false); }
public bool GetRecordOnResume() { if (Preference.Contains("record_on_resume")) { return(Preference.Get <bool>("record_on_resume")); } return(false); }
public bool GetVibrateFeedback() { if (Preference.Contains("vibrate_feedback")) { return(Preference.Get <bool>("vibrate_feedback")); } return(true); }
public override T Get <T>(string key, T defaultValue = default) { if (!Preference.Contains(key)) { return(defaultValue); } return(Preference.Get <T>(key)); }
protected override void NativeRemove(string[] keys) { foreach (var key in keys) { if (Preference.Contains(key)) { Preference.Remove(key); } } }
/// <summary> /// Removes a desired key from the settings /// </summary> /// <param name="key">Key for setting</param> /// <param name="fileName">Prefix for the key</param> public void Remove(string key, string fileName = null) { lock (locker) { var prefkey = GetFullPrefKey(key, fileName); if (Preference.Contains(prefkey)) { Preference.Remove(prefkey); } } }
public void Remove(string key, string sharedName) { lock (locker) { var fullKey = GetFullKey(key, sharedName); if (Preference.Contains(fullKey)) { Preference.Remove(fullKey); } } }
public static void Default() { Preference.RemoveAll(); if (!Preference.Contains(SettingsNames.TemperatureTypeSetting)) { SettingsVariables.TemperatureType = TemperatureType.C; } if (!Preference.Contains(SettingsNames.already_started)) { SettingsVariables.already_started = false; } }
/// <summary> /// Returns a value that indicates whether a specified key exists in the <see cref="ApplicationDataContainerSettings"/>. /// </summary> /// <param name="key">The key to check for in the <see cref="ApplicationDataContainerSettings"/>.</param> /// <returns>true if an item with that key exists in the <see cref="ApplicationDataContainerSettings"/>; otherwise, false. </returns> public bool ContainsKey(string key) { #if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 return(_settings.ContainsKey(key)); #elif __ANDROID__ || WINDOWS_PHONE || __UNIFIED__ return(DoContainsKey(key)); #elif TIZEN return(Preference.Contains(key)); #else throw new PlatformNotSupportedException(); #endif }
public static Task <List <Dialog>?> GetDialogs() { if (Preference.Contains(DialogsCacheKey)) { try { var json = Preference.Get <string>(DialogsCacheKey); var result = JsonConvert.DeserializeObject <List <Dialog> >(json); return(Task.FromResult <List <Dialog>?>(result)); } catch (Exception e) { Logger.Error(e); } } return(Task.FromResult <List <Dialog>?>(null)); }
public void LoadInfo() { tokenData = new GoogleTokenData(); if (!Preference.Contains("access_token") || !Preference.Contains("refresh_token") || !Preference.Contains("issued_date") || !Preference.Contains("expires")) { isLoggedIn = false; return; } tokenData.access_token = Preference.Get <string>("access_token"); tokenData.refresh_token = Preference.Get <string>("refresh_token"); tokenData.issued_date = DateTime.ParseExact(Preference.Get <string>("issued_date"), "yyyy-MM-dd HH:mm:ss", null); tokenData.expires_in = Preference.Get <int>("expires"); isLoggedIn = true; }
public DeviceInformation() { // Check whether STT feature is supported or not Information.TryGetValue(Features.STT, out isSpeechRecognitionSupported); // Check whether mic is available or not Information.TryGetValue(Features.Microphone, out isMicrophoneSupported); isFeatureSupported = isSpeechRecognitionSupported && isMicrophoneSupported; bool existing = Preference.Contains(LastUsedID); if (existing) { _numbering = Preference.Get <int>(LastUsedID); } else { _numbering = 0; } }
public Task <T> GetDataAsync <T>(string key) { try { if (Preference.Contains(key)) { var json = Preference.Get <string>(key); var data = JsonConvert.DeserializeObject <T>(json); LogUtil.Debug($"Found cached data for {key}"); return(Task.FromResult(data)); } else { LogUtil.Debug($"Missed cached data for {key}"); return(Task.FromResult(default(T))); } } catch (Exception) { return(Task.FromResult(default(T))); } }
T GetValueOrDefaultInternal <T>(string key, T defaultValue = default(T), string fileName = null) { lock (locker) { var prefkey = GetFullPrefKey(key, fileName); if (!Preference.Contains(prefkey)) { return(defaultValue); } Type typeOf = typeof(T); if (typeOf.GetTypeInfo().IsGenericType&& typeOf.GetGenericTypeDefinition() == typeof(Nullable <>)) { typeOf = Nullable.GetUnderlyingType(typeOf); } object value = null; var typeCode = Type.GetTypeCode(typeOf); switch (typeCode) { case TypeCode.Decimal: var savedDecimal = Preference.Get <string>(prefkey); value = Convert.ToDecimal(savedDecimal, System.Globalization.CultureInfo.InvariantCulture); break; case TypeCode.Boolean: value = Preference.Get <bool>(prefkey); break; case TypeCode.Int64: var savedInt64 = Preference.Get <string>(prefkey); value = Convert.ToInt64(savedInt64, System.Globalization.CultureInfo.InvariantCulture); break; case TypeCode.Double: value = Preference.Get <double>(prefkey); break; case TypeCode.String: value = Preference.Get <string>(prefkey); break; case TypeCode.Int32: value = Preference.Get <int>(prefkey); break; case TypeCode.Single: var savedSingle = Preference.Get <string>(prefkey); value = Convert.ToSingle(savedSingle, System.Globalization.CultureInfo.InvariantCulture); break; case TypeCode.DateTime: var savedTime = Preference.Get <string>(prefkey); if (string.IsNullOrWhiteSpace(savedTime)) { value = defaultValue; } else { var ticks = Convert.ToInt64(savedTime, System.Globalization.CultureInfo.InvariantCulture); if (ticks >= 0) { //Old value, stored before update to UTC values value = new DateTime(ticks); } else { //New value, UTC value = new DateTime(-ticks, DateTimeKind.Utc); } } break; default: if (defaultValue is Guid) { var outGuid = Guid.Empty; var savedGuid = Preference.Get <string>(prefkey); if (string.IsNullOrWhiteSpace(savedGuid)) { value = outGuid; } else { Guid.TryParse(savedGuid, out outGuid); value = outGuid; } } else { throw new ArgumentException($"Value of type {typeCode} is not supported."); } break; } return(null != value ? (T)value : defaultValue); } }
/// <summary> /// Check if the specified key exists or not /// </summary> /// <param name="key">key string</param> /// <returns>true if it exists</returns> public bool Contain(string key) { return(Preference.Contains(key)); }
public override bool Contains(string key) => Preference.Contains(key);