2016-03-25 09:22:24 +08:00
|
|
|
|
using System.Collections.Generic;
|
2016-05-05 08:57:03 +08:00
|
|
|
|
using Wox.Plugin;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
|
2016-06-19 23:18:43 +08:00
|
|
|
|
namespace Wox.Infrastructure.UserSettings
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
2016-05-24 05:08:13 +08:00
|
|
|
|
public class PluginsSettings : BaseModel
|
2016-05-05 08:57:03 +08:00
|
|
|
|
{
|
|
|
|
|
public string PythonDirectory { get; set; }
|
|
|
|
|
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
|
|
|
|
|
|
2016-05-12 09:45:35 +08:00
|
|
|
|
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
|
2016-05-05 08:57:03 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (var metadata in metadatas)
|
|
|
|
|
{
|
|
|
|
|
if (Plugins.ContainsKey(metadata.ID))
|
|
|
|
|
{
|
|
|
|
|
var settings = Plugins[metadata.ID];
|
|
|
|
|
if (settings.ActionKeywords?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
metadata.ActionKeywords = settings.ActionKeywords;
|
|
|
|
|
metadata.ActionKeyword = settings.ActionKeywords[0];
|
|
|
|
|
}
|
2016-05-22 12:30:38 +08:00
|
|
|
|
metadata.Disabled = settings.Disabled;
|
2016-05-05 08:57:03 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Plugins[metadata.ID] = new Plugin
|
|
|
|
|
{
|
|
|
|
|
ID = metadata.ID,
|
|
|
|
|
Name = metadata.Name,
|
|
|
|
|
ActionKeywords = metadata.ActionKeywords,
|
2019-10-23 13:18:21 +08:00
|
|
|
|
Disabled = metadata.Disabled
|
2016-05-05 08:57:03 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class Plugin
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
|
|
|
|
public string ID { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
2015-11-06 10:29:32 +08:00
|
|
|
|
public List<string> ActionKeywords { get; set; }
|
2014-07-01 22:19:46 +08:00
|
|
|
|
public bool Disabled { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|