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

@@ -1,45 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
namespace Wox.Plugin.Program
{
[Serializable]
public class ProgramStorage : JsonStrorage<ProgramStorage>
public class Settings
{
[JsonProperty]
public List<ProgramSource> ProgramSources { get; set; }
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"};
public bool EnableStartMenuSource { get; set; } = true;
[JsonProperty]
public string[] ProgramSuffixes { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
[DefaultValue(true)]
public bool EnableStartMenuSource { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
[DefaultValue(true)]
public bool EnableRegistrySource { get; set; }
protected override ProgramStorage LoadDefault()
{
ProgramSources = new List<ProgramSource>();
EnableStartMenuSource = true;
EnableRegistrySource = true;
return this;
}
protected override void OnAfterLoad(ProgramStorage storage)
{
if (storage.ProgramSuffixes == null || storage.ProgramSuffixes.Length == 0)
{
storage.ProgramSuffixes = new[] {"bat", "appref-ms", "exe", "lnk"};
}
}
protected override string FileName { get; } = "settings_plugin_program";
public bool EnableRegistrySource { get; set; } = true;
}
}