Remove unneccessary api, rename storage api, and update comment

This commit is contained in:
张弘韬 2021-05-13 19:29:21 +08:00
parent dea26c684a
commit d84eff7712
11 changed files with 16 additions and 26 deletions

View file

@ -165,30 +165,20 @@ namespace Flow.Launcher.Plugin
void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "");
/// <summary>
/// Load JsonStorage for current plugin. This is the method used to load settings from json in Flow.
/// Load JsonStorage for current plugin's setting. This is the method used to load settings from json in Flow.
/// When the file is not exist, it will create a new instance for the specific type.
/// </summary>
/// <typeparam name="T">Type for deserialization</typeparam>
/// <returns></returns>
T LoadJsonStorage<T>() where T : new();
T LoadSettingJsonStorage<T>() where T : new();
/// <summary>
/// Save JsonStorage for current plugin. This is the method used to save settings to json in Flow.Launcher
/// Save JsonStorage for current plugin's setting. This is the method used to save settings to json in Flow.Launcher
/// This method will save the original instance loaded with LoadJsonStorage.
/// This API call is for manually Save. Flow will automatically save all setting that has registered.
/// </summary>
/// <typeparam name="T">Type for Serialization</typeparam>
/// <returns></returns>
void SaveJsonStorage<T>() where T : new();
/// <summary>
/// Save JsonStorage for current plugin. This is the method used to save settings to json in Flow.Launcher
/// This method will override the original class instance loaded from LoadJsonStorage
/// This method allows registering a type with provided instance so that it won't create a new one.
/// Only use it when you would like to create a new instance of the type instance and overwrite the original one
/// stored before.
/// </summary>
/// <typeparam name="T">Type for Serialization</typeparam>
/// <returns></returns>
void SaveJsonStorage<T>(T settings) where T : new();
void SaveSettingJsonStorage<T>() where T : new();
}
}

View file

@ -145,7 +145,7 @@ namespace Flow.Launcher
}
}
public T LoadJsonStorage<T>() where T : new()
public T LoadSettingJsonStorage<T>() where T : new()
{
var type = typeof(T);
if (!_pluginJsonStorages.ContainsKey(type))
@ -154,7 +154,7 @@ namespace Flow.Launcher
return ((PluginJsonStorage<T>) _pluginJsonStorages[type]).Load();
}
public void SaveJsonStorage<T>() where T : new()
public void SaveSettingJsonStorage<T>() where T : new()
{
var type = typeof(T);
if (!_pluginJsonStorages.ContainsKey(type))

View file

@ -24,7 +24,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
{
this.context = context;
_settings = context.API.LoadJsonStorage<Settings>();
_settings = context.API.LoadSettingJsonStorage<Settings>();
cachedBookmarks = Bookmarks.LoadAllBookmarks();
}

View file

@ -33,7 +33,7 @@ namespace Flow.Launcher.Plugin.Caculator
public void Init(PluginInitContext context)
{
Context = context;
_settings = context.API.LoadJsonStorage<Settings>();
_settings = context.API.LoadSettingJsonStorage<Settings>();
_viewModel = new SettingsViewModel(_settings);
MagesEngine = new Engine(new Configuration

View file

@ -32,7 +32,7 @@ namespace Flow.Launcher.Plugin.Explorer
{
Context = context;
Settings = context.API.LoadJsonStorage<Settings>();
Settings = context.API.LoadSettingJsonStorage<Settings>();
viewModel = new SettingsViewModel(context, Settings);

View file

@ -22,7 +22,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
public void Save()
{
Context.API.SaveJsonStorage<Settings>();
Context.API.SaveSettingJsonStorage<Settings>();
}
internal void RemoveLinkFromQuickAccess(AccessLink selectedRow) => Settings.QuickAccessLinks.Remove(selectedRow);

View file

@ -34,7 +34,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
public Task InitAsync(PluginInitContext context)
{
Context = context;
Settings = context.API.LoadJsonStorage<Settings>();
Settings = context.API.LoadSettingJsonStorage<Settings>();
viewModel = new SettingsViewModel(context, Settings);
contextMenu = new ContextMenu(Context);
pluginManager = new PluginsManager(Context, Settings);

View file

@ -69,7 +69,7 @@ namespace Flow.Launcher.Plugin.Program
{
_context = context;
_settings = context.API.LoadJsonStorage<Settings>();
_settings = context.API.LoadSettingJsonStorage<Settings>();
await Task.Yield();

View file

@ -272,7 +272,7 @@ namespace Flow.Launcher.Plugin.Shell
{
this.context = context;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
_settings = context.API.LoadJsonStorage<Settings>();
_settings = context.API.LoadSettingJsonStorage<Settings>();
}
bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)

View file

@ -118,7 +118,7 @@ namespace Flow.Launcher.Plugin.Url
{
this.context = context;
_settings = context.API.LoadJsonStorage<Settings>();
_settings = context.API.LoadSettingJsonStorage<Settings>();
}
public string GetTranslatedPluginTitle()

View file

@ -168,7 +168,7 @@ namespace Flow.Launcher.Plugin.WebSearch
{
_context = context;
_settings = _context.API.LoadJsonStorage<Settings>();
_settings = _context.API.LoadSettingJsonStorage<Settings>();
_viewModel = new SettingsViewModel(_settings);
var pluginDirectory = _context.CurrentPluginMetadata.PluginDirectory;