Refactored core
UI navigation framework Related Work Items: #408, #414, #416
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace FoxTube.Services
|
||||
{
|
||||
public static class StorageService
|
||||
{
|
||||
private static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
|
||||
|
||||
public static StorageFolder Folder => ApplicationData.Current.RoamingFolder;
|
||||
|
||||
public static bool PromptFeedback
|
||||
{
|
||||
get => GetValue(Uptime.TotalHours > 12);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static bool PromptReview
|
||||
{
|
||||
get => GetValue(Uptime.TotalHours > 24);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static TimeSpan Uptime
|
||||
{
|
||||
get => GetValue(TimeSpan.FromSeconds(0));
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static DateTime LastInboxCheck
|
||||
{
|
||||
get => GetValue(DateTime.UtcNow);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static string LastOpenedVersion
|
||||
{
|
||||
get => GetValue(null);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static int? LastUserIndex
|
||||
{
|
||||
get => GetValue(null);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static string UserInfos
|
||||
{
|
||||
get => GetValue(null);
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public static async Task ClearStorage()
|
||||
{
|
||||
storage.Values.Clear();
|
||||
foreach (IStorageItem i in await Folder.GetItemsAsync())
|
||||
await i.DeleteAsync();
|
||||
}
|
||||
|
||||
#region Service methods
|
||||
private static dynamic GetValue(object defaultValue)
|
||||
{
|
||||
string propName = (new StackTrace()).GetFrame(1).GetMethod().Name.Substring(4);
|
||||
return storage.Values[$"Storage.{propName}"] ?? defaultValue;
|
||||
}
|
||||
|
||||
private static void SetValue(object value)
|
||||
{
|
||||
string propName = (new StackTrace()).GetFrame(1).GetMethod().Name.Substring(4);
|
||||
storage.Values[$"Storage.{propName}"] = value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user