mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use ISavable interface instead of reflection
This commit is contained in:
parent
e6d3d0fa9e
commit
6e5c7ad190
3 changed files with 11 additions and 8 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using MemoryPack;
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
/// <remarks>
|
||||
/// It utilize MemoryPack, which means the object must be MemoryPackSerializable <see href="https://github.com/Cysharp/MemoryPack"/>
|
||||
/// </remarks>
|
||||
public class BinaryStorage<T>
|
||||
public class BinaryStorage<T> : ISavable
|
||||
{
|
||||
protected T? Data;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
#nullable enable
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Flow.Launcher.Infrastructure.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Serialize object using json format.
|
||||
/// </summary>
|
||||
public class JsonStorage<T> where T : new()
|
||||
public class JsonStorage<T> : ISavable where T : new()
|
||||
{
|
||||
protected T? Data;
|
||||
|
||||
|
|
|
|||
|
|
@ -225,8 +225,8 @@ namespace Flow.Launcher
|
|||
{
|
||||
foreach (var value in _pluginJsonStorages.Values)
|
||||
{
|
||||
var method = value.GetType().GetMethod("Save");
|
||||
method?.Invoke(value, null);
|
||||
var savable = value as ISavable;
|
||||
savable?.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -368,8 +368,8 @@ namespace Flow.Launcher
|
|||
{
|
||||
foreach (var value in _pluginBinaryStorages.Values)
|
||||
{
|
||||
var method = value.GetType().GetMethod("Save");
|
||||
method?.Invoke(value, null);
|
||||
var savable = value as ISavable;
|
||||
savable?.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue