update class name

This commit is contained in:
Jeremy Wu 2021-06-21 21:31:07 +10:00
parent 6ec151a8ab
commit 0387bfbb64
2 changed files with 4 additions and 19 deletions

View file

@ -3,9 +3,9 @@ using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.Infrastructure.Storage namespace Flow.Launcher.Infrastructure.Storage
{ {
public class PluginJsonSettingStorage<T> :JsonStorage<T> where T : new() public class PluginJsonStorage<T> :JsonStorage<T> where T : new()
{ {
public PluginJsonSettingStorage() public PluginJsonStorage()
{ {
// C# related, add python related below // C# related, add python related below
var dataType = typeof(T); var dataType = typeof(T);
@ -16,25 +16,10 @@ namespace Flow.Launcher.Infrastructure.Storage
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}"); FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
} }
public PluginJsonSettingStorage(T data) : this() public PluginJsonStorage(T data) : this()
{ {
_data = data; _data = data;
} }
} }
public class PluginJsonStorage<T> : JsonStrorage<T> where T : new()
{
public PluginJsonStorage()
{
// C# releated, add python releated below
var dataType = typeof(T);
var assemblyName = typeof(T).Assembly.GetName().Name;
DirectoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Plugins, assemblyName);
Helper.ValidateDirectory(DirectoryPath);
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
}
}
} }

View file

@ -177,7 +177,7 @@ namespace Flow.Launcher
public void SaveJsonStorage<T>(T settings) where T : new() public void SaveJsonStorage<T>(T settings) where T : new()
{ {
var type = typeof(T); var type = typeof(T);
_pluginJsonStorages[type] = new PluginJsonSettingStorage<T>(settings); _pluginJsonStorages[type] = new PluginJsonStorage<T>(settings);
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save(); ((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
} }