Remove instance logic for BinaryStorage and JsonStorage, part 1

1. part of #389
2. huge refactoring
This commit is contained in:
bao-qian
2016-04-21 01:53:21 +01:00
parent 0bcb76fa81
commit 8d10c9aa41
52 changed files with 502 additions and 584 deletions

View File

@@ -8,6 +8,7 @@ using WindowsInput;
using WindowsInput.Native;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage;
using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.CMD
@@ -17,7 +18,20 @@ namespace Wox.Plugin.CMD
private PluginInitContext context;
private bool WinRStroked;
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
private readonly CMDStorage _settings = CMDStorage.Instance;
private readonly CMDHistory _settings;
private readonly PluginSettingsStorage<CMDHistory> _storage;
public CMD()
{
_storage = new PluginSettingsStorage<CMDHistory>();
_settings = _storage.Load();
}
~CMD()
{
_storage.Save();
}
public List<Result> Query(Query query)
{
@@ -81,7 +95,7 @@ namespace Wox.Plugin.CMD
private List<Result> GetHistoryCmds(string cmd, Result result)
{
IEnumerable<Result> history = _settings.CMDHistory.Where(o => o.Key.Contains(cmd))
IEnumerable<Result> history = _settings.Count.Where(o => o.Key.Contains(cmd))
.OrderByDescending(o => o.Value)
.Select(m =>
{
@@ -127,7 +141,7 @@ namespace Wox.Plugin.CMD
private List<Result> ResultsFromlHistory()
{
IEnumerable<Result> history = _settings.CMDHistory.OrderByDescending(o => o.Value)
IEnumerable<Result> history = _settings.Count.OrderByDescending(o => o.Value)
.Select(m => new Result
{
Title = m.Key,