Settings.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Diagnostics;
  3. using Windows.Foundation.Collections;
  4. using Windows.Storage;
  5. using YJMPD_UWP.Model.Object;
  6. namespace YJMPD_UWP.Helpers
  7. {
  8. static class Settings
  9. {
  10. public static IPropertySet Values = ApplicationData.Current.LocalSettings.Values;
  11. static Settings()
  12. {
  13. //Define default settings here
  14. Values["hostname"] = "imegumii.space";
  15. if (Values["username"] == null)
  16. Values["username"] = "Anon_" + Util.Random(5, Util.RandomType.ALPHANUMERIC);
  17. if (Values["statistics"] == null)
  18. Values["statistics"] = Util.Serialize(new Statistics());
  19. st = Util.Deserialize<Statistics>(Values["statistics"] as string);
  20. }
  21. private static Statistics st;
  22. public static Statistics Statistics
  23. {
  24. get
  25. {
  26. return st;
  27. }
  28. }
  29. public static string Username
  30. {
  31. get
  32. {
  33. return Values["username"] as string;
  34. }
  35. set
  36. {
  37. Values["username"] = value;
  38. }
  39. }
  40. }
  41. }