From 062cd2ad1dc8dd8327a6a2cebdbd58e478c362d9 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 6 Jun 2025 18:38:05 +0800 Subject: [PATCH] Use ISavable instead of object --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 2 +- Flow.Launcher/PublicAPIInstance.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 003e72a5d..435d97ab7 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -12,7 +12,7 @@ using Flow.Launcher.Plugin; namespace Flow.Launcher.Core.Plugin { - public class JsonRPCPluginSettings + public class JsonRPCPluginSettings : ISavable { public required JsonRpcConfigurationModel? Configuration { get; init; } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 80d5de53d..06e17baf0 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -276,7 +276,7 @@ namespace Flow.Launcher public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName); - private readonly ConcurrentDictionary _pluginJsonStorages = new(); + private readonly ConcurrentDictionary _pluginJsonStorages = new(); public void RemovePluginSettings(string assemblyName) { @@ -294,9 +294,8 @@ namespace Flow.Launcher public void SavePluginSettings() { - foreach (var value in _pluginJsonStorages.Values) + foreach (var savable in _pluginJsonStorages.Values) { - var savable = value as ISavable; savable?.Save(); } } @@ -496,7 +495,7 @@ namespace Flow.Launcher public bool SetCurrentTheme(ThemeData theme) => 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) { @@ -513,9 +512,8 @@ namespace Flow.Launcher public void SavePluginCaches() { - foreach (var value in _pluginBinaryStorages.Values) + foreach (var savable in _pluginBinaryStorages.Values) { - var savable = value as ISavable; savable?.Save(); } }