PowerToys/Wox.Infrastructure/UserSettings/PluginSettings.cs
bao-qian 6e13440f1f MVVM refactoring for web search plugin, part 1
1. #486
2. fix #778 #763 #742
3. MVVM refactoring
4. remove IMultipleActionKeywords interface, use PluginManager directly
2016-06-21 00:14:32 +01:00

46 lines
1.5 KiB
C#

using System.Collections.Generic;
using Wox.Plugin;
namespace Wox.Infrastructure.UserSettings
{
public class PluginsSettings : BaseModel
{
public string PythonDirectory { get; set; }
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
{
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];
}
metadata.Disabled = settings.Disabled;
}
else
{
Plugins[metadata.ID] = new Plugin
{
ID = metadata.ID,
Name = metadata.Name,
ActionKeywords = metadata.ActionKeywords,
Disabled = false
};
}
}
}
}
public class Plugin
{
public string ID { get; set; }
public string Name { get; set; }
public List<string> ActionKeywords { get; set; }
public bool Disabled { get; set; }
}
}