public static async Task AddReplaceBinary <T>(AppProperty key, T value) where T : class { var bytes = SerialiserHelper.ToBytes(value); Application myApp = Application.Current; bool check = myApp.Properties.ContainsKey(key.ToString()); if (check) { myApp.Properties.Remove(key.ToString()); } myApp.Properties.Add(key.ToString(), bytes); await myApp.SavePropertiesAsync(); }
public static async Task <T> GetBinary <T>(AppProperty key) where T : class { Application myApp = Application.Current; bool check = myApp.Properties.ContainsKey(key.ToString()); if (check) { var property = myApp.Properties[key.ToString()]; if (property is null) { await Clear(key); return(default(T)); } var result = SerialiserHelper.FromBytes <T>((byte[])property); return(result); } return(default(T)); }