Settings.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Helpers/Settings.cs
  2. using Plugin.Settings;
  3. using Plugin.Settings.Abstractions;
  4. namespace MyWeather.Helpers
  5. {
  6. /// <summary>
  7. /// This is the Settings static class that can be used in your Core solution or in any
  8. /// of your client applications. All settings are laid out the same exact way with getters
  9. /// and setters.
  10. /// </summary>
  11. public static class Settings
  12. {
  13. private static ISettings AppSettings
  14. {
  15. get
  16. {
  17. return CrossSettings.Current;
  18. }
  19. }
  20. #region Setting Constants
  21. private const string IsImperialKey = "is_imperial";
  22. private static readonly bool IsImperialDefault = true;
  23. private const string UseCityKey = "use_city";
  24. private static readonly bool UseCityDefault = true;
  25. private const string CityKey = "city";
  26. private static readonly string CityDefault = "Seattle,WA";
  27. #endregion
  28. public static bool IsImperial
  29. {
  30. get
  31. {
  32. return AppSettings.GetValueOrDefault(IsImperialKey, IsImperialDefault);
  33. }
  34. set
  35. {
  36. AppSettings.AddOrUpdateValue(IsImperialKey, value);
  37. }
  38. }
  39. public static bool UseCity
  40. {
  41. get
  42. {
  43. return AppSettings.GetValueOrDefault(UseCityKey, UseCityDefault);
  44. }
  45. set
  46. {
  47. AppSettings.AddOrUpdateValue(UseCityKey, value);
  48. }
  49. }
  50. public static string City
  51. {
  52. get
  53. {
  54. return AppSettings.GetValueOrDefault(CityKey, CityDefault);
  55. }
  56. set
  57. {
  58. AppSettings.AddOrUpdateValue(CityKey, value);
  59. }
  60. }
  61. }
  62. }