Archived
1
0

Core refactoring (app doesn't work)

This commit is contained in:
Michael Gordeev
2020-05-09 23:16:19 +03:00
parent 2b1f06dd93
commit 2a987e33a2
35 changed files with 1135 additions and 817 deletions
+32
View File
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Windows.Storage;
namespace FoxTube.Services
{
public static class History
{
static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
public static string[] SearchHistory
{
get => JsonConvert.DeserializeObject<string[]>(storage.Values["SearchHistory"] as string) ?? new string[0];
private set => JsonConvert.SerializeObject(value);
}
public static void AddSearchHistoryEntry(string term)
{
List<string> history = SearchHistory.ToList();
history.Insert(0, term);
if (history.Count > 5)
history.RemoveRange(5, history.Count - 5);
SearchHistory = history.ToArray();
}
public static void ClearSearchHistory() =>
SearchHistory = new string[0];
}
}