Flow.Launcher/Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs

36 lines
1 KiB
C#
Raw Normal View History

using System.IO;
2020-04-21 09:12:17 +00:00
using Flow.Launcher.Infrastructure.UserSettings;
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Infrastructure.Storage
{
public class PluginJsonStorage<T> : JsonStorage<T> where T : new()
{
// Use assembly name to check which plugin is using this storage
public readonly string AssemblyName;
2021-06-21 11:31:07 +00:00
public PluginJsonStorage()
{
2021-05-11 19:10:03 +00:00
// C# related, add python related below
var dataType = typeof(T);
AssemblyName = dataType.Assembly.GetName().Name;
DirectoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Plugins, AssemblyName);
Helper.ValidateDirectory(DirectoryPath);
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
}
2021-06-21 11:31:07 +00:00
public PluginJsonStorage(T data) : this()
{
2023-01-07 19:11:43 +00:00
Data = data;
}
public void DeleteDirectory()
{
if (Directory.Exists(DirectoryPath))
{
Directory.Delete(DirectoryPath, true);
}
}
}
}