public object GetValue(Type valueType, string key) { object value = null; if (valueType == typeof(string)) { value = UserDefaults.StringForKey(key); } else if (valueType == typeof(int)) { value = UserDefaults.IntForKey(key); } else if (valueType == typeof(bool)) { value = UserDefaults.BoolForKey(key); } else if (valueType == typeof(float)) { value = UserDefaults.FloatForKey(key); } else if (valueType == typeof(double)) { value = UserDefaults.DoubleForKey(key); } else if (valueType == typeof(long)) { value = (long)((NSNumber)UserDefaults.ValueForKey(new NSString(key))); } else { Log.Error(INCORRECT_VALUE_TYPE_ERROR); } return(value); }
internal void ReloadAppSettings() { _settings.API_Key = _defaults.StringForKey(DefaultKeys.API_KEY); _settings.API_Secret = _defaults.StringForKey(DefaultKeys.API_SECRET); _settings.RefreshRate = _defaults.FloatForKey(DefaultKeys.REFRESH_RATE); _settings.AutoStart = _defaults.BoolForKey(DefaultKeys.AUTO_START); }
private T Get <T>(string key, NSUserDefaults defaults) { object result; switch (Type.GetTypeCode(typeof(T))) { case TypeCode.Boolean: result = (bool)defaults.BoolForKey(key); break; case TypeCode.Int32: result = (int)defaults.IntForKey(key); break; case TypeCode.Single: result = (float)defaults.FloatForKey(key); break; case TypeCode.String: result = (string)defaults.StringForKey(key); break; default: throw new NotSupportedException($"{typeof(T)} is not supported."); } return((T)result); }
public static float FloatForKey(this NSUserDefaults defaults, float defaultValue, string key) { if (defaults.ValueForKey(new NSString(key)) == null) { return(defaultValue); } return(defaults.FloatForKey(key)); }
void LePreferencias() { txtNome.Text = prefs.StringForKey("user"); boolSwitch.SetState(prefs.BoolForKey("habilitado"), true); floatSlider.Value = prefs.FloatForKey("slider"); lblInt.Text = prefs.IntForKey("int").ToString(); intStepper.Value = prefs.IntForKey("int"); dtPicker.Date = NSDate.FromTimeIntervalSince1970(prefs.DoubleForKey("data")); }
static public float GetFloatSetting(string name, float defValue = 0) { float res = g_prefs.FloatForKey(name); if (res == 0.0 && defValue != 0.0) { res = defValue; } return(res); }
public float GetFloat(string key) { try { return(_defaults.FloatForKey(key)); } catch (Exception e) { Logger.Error($"Error Getting Float UserSetting {key} - {e.Message}", e); } return(0); }
private void RefreshFields() { NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; ServiceSlider.Value = defaults.FloatForKey(Constants.TIPPERCENTAGE_KEY); TaxPercentageText.Text = defaults.StringForKey(Constants.TAXPERCENTAGE_KEY); tipCalc.currencyType = defaults.StringForKey(Constants.CURRENCYTYPE_KEY); UIColor color = UIColor.White; string colorString = defaults.StringForKey(Constants.BACKGROUNDCOLOR_KEY); if (colorString == "White") { color = UIColor.White; } else if (colorString == "Green") { color = UIColor.Green; } else { color = UIColor.Blue; } this.View.BackgroundColor = color; }
/// <inheritdoc /> public float GetFloat(string key, float defaultValue) { return(_standardDefaults.FloatForKey(defaultValue, key)); }