2016-04-21 00:53:21 +00:00
|
|
|
|
using System.IO;
|
2020-04-21 09:12:17 +00:00
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
2016-04-21 00:53:21 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.Infrastructure.Storage
|
2016-04-21 00:53:21 +00:00
|
|
|
|
{
|
2021-05-11 19:10:03 +00:00
|
|
|
|
public class PluginJsonStorage<T> :JsonStorage<T> where T : new()
|
2016-04-21 00:53:21 +00:00
|
|
|
|
{
|
2016-04-26 21:45:31 +00:00
|
|
|
|
public PluginJsonStorage()
|
2016-04-21 00:53:21 +00:00
|
|
|
|
{
|
2021-05-11 19:10:03 +00:00
|
|
|
|
// C# related, add python related below
|
2017-02-07 00:21:39 +00:00
|
|
|
|
var dataType = typeof(T);
|
2021-05-12 11:38:29 +00:00
|
|
|
|
var assemblyName = dataType.Assembly.GetName().Name;
|
2020-04-01 11:20:33 +00:00
|
|
|
|
DirectoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Plugins, assemblyName);
|
2017-02-07 00:21:39 +00:00
|
|
|
|
Helper.ValidateDirectory(DirectoryPath);
|
2016-04-27 01:15:53 +00:00
|
|
|
|
|
2017-02-07 00:21:39 +00:00
|
|
|
|
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
|
2016-04-21 00:53:21 +00:00
|
|
|
|
}
|
2021-02-14 10:08:30 +00:00
|
|
|
|
|
|
|
|
|
|
public PluginJsonStorage(T data) : this()
|
|
|
|
|
|
{
|
|
|
|
|
|
_data = data;
|
|
|
|
|
|
}
|
2016-04-21 00:53:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|