mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add Logs, LoadJsonStorage, SaveJsonStorage to IPublicAPI
This commit is contained in:
parent
6a318685a4
commit
f8557da336
4 changed files with 57 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
public class JsonStrorage<T> where T : new()
|
||||
{
|
||||
private readonly JsonSerializerOptions _serializerSettings;
|
||||
private T _data;
|
||||
protected T _data;
|
||||
// need a new directory name
|
||||
public const string DirectoryName = "Settings";
|
||||
public const string FileSuffix = ".json";
|
||||
|
|
|
|||
|
|
@ -15,5 +15,10 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
|
||||
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
|
||||
}
|
||||
|
||||
public PluginJsonStorage(T data) : this()
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using JetBrains.Annotations;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -100,5 +101,16 @@ namespace Flow.Launcher.Plugin
|
|||
|
||||
void RemoveActionKeyword(string pluginId, string oldActionKeyword);
|
||||
|
||||
void LogDebug(string className, string message, [CallerMemberName] string methodName = "");
|
||||
|
||||
void LogInfo(string className, string message, [CallerMemberName] string methodName = "");
|
||||
|
||||
void LogWarn(string className, string message, [CallerMemberName] string methodName = "");
|
||||
|
||||
void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "");
|
||||
|
||||
T LoadJsonStorage<T>(PluginMetadata metadata) where T : new();
|
||||
|
||||
void SaveJsonStorage<T>(PluginMetadata metadata, T setting) where T : new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ using System.Threading;
|
|||
using System.IO;
|
||||
using Flow.Launcher.Infrastructure.Http;
|
||||
using JetBrains.Annotations;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -160,6 +163,41 @@ namespace Flow.Launcher
|
|||
{
|
||||
PluginManager.RemoveActionKeyword(pluginId, oldActionKeyword);
|
||||
}
|
||||
|
||||
|
||||
public void LogDebug(string className, string message, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
Log.Debug(className, message, methodName);
|
||||
}
|
||||
|
||||
public void LogInfo(string className, string message, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
Log.Info(className, message, methodName);
|
||||
}
|
||||
|
||||
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
Log.Warn(className, message, methodName);
|
||||
}
|
||||
|
||||
public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
Log.Exception(className, message, e, methodName);
|
||||
}
|
||||
|
||||
public T LoadJsonStorage<T>(PluginMetadata metadata) where T : new()
|
||||
{
|
||||
var storage = new PluginJsonStorage<T>();
|
||||
return storage.Load();
|
||||
}
|
||||
|
||||
public void SaveJsonStorage<T>(PluginMetadata metadata, T setting) where T : new()
|
||||
{
|
||||
var storage = new PluginJsonStorage<T>(setting);
|
||||
storage.Save();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
|
@ -173,6 +211,7 @@ namespace Flow.Launcher
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue