PowerToys/Wox/Storage/UserSelectedRecord.cs

37 lines
825 B
C#
Raw Normal View History

2015-10-31 07:17:34 +08:00
using System.Collections.Generic;
2014-03-23 16:17:41 +08:00
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
2014-12-26 22:51:04 +08:00
namespace Wox.Storage
2014-03-23 16:17:41 +08:00
{
public class UserSelectedRecord
2014-03-23 16:17:41 +08:00
{
[JsonProperty]
private Dictionary<string, int> records = new Dictionary<string, int>();
public void Add(Result result)
{
2019-12-04 05:37:55 +08:00
var key = result.ToString();
if (records.TryGetValue(key, out int value))
2014-03-23 16:17:41 +08:00
{
2019-12-04 05:37:55 +08:00
records[key] = value + 1;
2014-03-23 16:17:41 +08:00
}
else
{
2019-12-04 05:37:55 +08:00
records.Add(key, 1);
2014-03-23 16:17:41 +08:00
}
}
public int GetSelectedCount(Result result)
{
2019-12-04 05:37:55 +08:00
if (records.TryGetValue(result.ToString(), out int value))
2014-03-23 16:17:41 +08:00
{
2019-12-04 05:37:55 +08:00
return value;
2014-03-23 16:17:41 +08:00
}
return 0;
}
}
}