mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
close #48 Refactor setting storage.
This commit is contained in:
43
Wox.Infrastructure/Storage/UserSelectedRecordStorage.cs
Normal file
43
Wox.Infrastructure/Storage/UserSelectedRecordStorage.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
public class UserSelectedRecordStorage : BaseStorage<UserSelectedRecordStorage>
|
||||
{
|
||||
[JsonProperty]
|
||||
private Dictionary<string, int> records = new Dictionary<string, int>();
|
||||
|
||||
protected override string ConfigName
|
||||
{
|
||||
get { return "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user