mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 19:19:23 +08:00
40 lines
998 B
C#
40 lines
998 B
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using Newtonsoft.Json;
|
|
using Wox.Infrastructure.Storage;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Storage
|
|
{
|
|
public class UserSelectedRecordStorage : JsonStrorage<UserSelectedRecordStorage>
|
|
{
|
|
[JsonProperty]
|
|
private Dictionary<string, int> records = new Dictionary<string, int>();
|
|
|
|
protected override string FileName { get; } = "UserSelectedRecords";
|
|
|
|
public void Add(Result result)
|
|
{
|
|
if (records.ContainsKey(result.ToString()))
|
|
{
|
|
records[result.ToString()] += 1;
|
|
}
|
|
else
|
|
{
|
|
records.Add(result.ToString(), 1);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public int GetSelectedCount(Result result)
|
|
{
|
|
if (records.ContainsKey(result.ToString()))
|
|
{
|
|
return records[result.ToString()];
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
}
|