Use ISavable instead of object

This commit is contained in:
Jack251970 2025-06-06 18:38:05 +08:00
parent baef9ddacd
commit 062cd2ad1d
2 changed files with 5 additions and 7 deletions

View file

@ -12,7 +12,7 @@ using Flow.Launcher.Plugin;
namespace Flow.Launcher.Core.Plugin namespace Flow.Launcher.Core.Plugin
{ {
public class JsonRPCPluginSettings public class JsonRPCPluginSettings : ISavable
{ {
public required JsonRpcConfigurationModel? Configuration { get; init; } public required JsonRpcConfigurationModel? Configuration { get; init; }

View file

@ -276,7 +276,7 @@ namespace Flow.Launcher
public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") => public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") =>
Log.Exception(className, message, e, methodName); Log.Exception(className, message, e, methodName);
private readonly ConcurrentDictionary<Type, object> _pluginJsonStorages = new(); private readonly ConcurrentDictionary<Type, ISavable> _pluginJsonStorages = new();
public void RemovePluginSettings(string assemblyName) public void RemovePluginSettings(string assemblyName)
{ {
@ -294,9 +294,8 @@ namespace Flow.Launcher
public void SavePluginSettings() public void SavePluginSettings()
{ {
foreach (var value in _pluginJsonStorages.Values) foreach (var savable in _pluginJsonStorages.Values)
{ {
var savable = value as ISavable;
savable?.Save(); savable?.Save();
} }
} }
@ -496,7 +495,7 @@ namespace Flow.Launcher
public bool SetCurrentTheme(ThemeData theme) => public bool SetCurrentTheme(ThemeData theme) =>
Theme.ChangeTheme(theme.FileNameWithoutExtension); Theme.ChangeTheme(theme.FileNameWithoutExtension);
private readonly ConcurrentDictionary<(string, string, Type), object> _pluginBinaryStorages = new(); private readonly ConcurrentDictionary<(string, string, Type), ISavable> _pluginBinaryStorages = new();
public void RemovePluginCaches(string cacheDirectory) public void RemovePluginCaches(string cacheDirectory)
{ {
@ -513,9 +512,8 @@ namespace Flow.Launcher
public void SavePluginCaches() public void SavePluginCaches()
{ {
foreach (var value in _pluginBinaryStorages.Values) foreach (var savable in _pluginBinaryStorages.Values)
{ {
var savable = value as ISavable;
savable?.Save(); savable?.Save();
} }
} }