From 3d47d2409d14ccc25e4dacfef7ac35cb85715667 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Wed, 7 Jul 2021 16:09:14 +0800 Subject: [PATCH] Move all interface to Features.cs --- Flow.Launcher.Plugin/Features.cs | 87 +++++++++++++++++++ Flow.Launcher.Plugin/Interfaces/Feature.cs | 40 --------- .../Interfaces/IAsyncReloadable.cs | 20 ----- .../Interfaces/IReloadable.cs | 22 ----- Flow.Launcher.Plugin/Interfaces/ISavable.cs | 12 --- 5 files changed, 87 insertions(+), 94 deletions(-) create mode 100644 Flow.Launcher.Plugin/Features.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/Feature.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/IReloadable.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/ISavable.cs diff --git a/Flow.Launcher.Plugin/Features.cs b/Flow.Launcher.Plugin/Features.cs new file mode 100644 index 000000000..4b7e03718 --- /dev/null +++ b/Flow.Launcher.Plugin/Features.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Threading; +using System.Threading.Tasks; + +namespace Flow.Launcher.Plugin +{ + public interface IFeatures + { + } + + public interface IContextMenu : IFeatures + { + List LoadContextMenus(Result selectedResult); + } + + /// + /// Represent plugins that support internationalization + /// + public interface IPluginI18n : IFeatures + { + string GetTranslatedPluginTitle(); + + string GetTranslatedPluginDescription(); + } + + public interface IResultUpdated : IFeatures + { + event ResultUpdatedEventHandler ResultsUpdated; + } + + public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); + + public class ResultUpdatedEventArgs : EventArgs + { + public List Results; + public Query Query; + public CancellationToken Token { get; init; } = default; + } + + /// + /// This interface is to indicate and allow plugins to asyncronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + public interface IAsyncReloadable : IFeatures + { + Task ReloadDataAsync(); + } + + /// + /// This interface is to indicate and allow plugins to synchronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + /// + /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface + /// + /// + public interface IReloadable : IFeatures + { + void ReloadData(); + } + + /// + /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, + /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, + /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow + /// + public interface ISavable : IFeatures + { + void Save(); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/Interfaces/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Feature.cs deleted file mode 100644 index eaffea28e..000000000 --- a/Flow.Launcher.Plugin/Interfaces/Feature.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Threading; - -namespace Flow.Launcher.Plugin -{ - public interface IFeatures - { - } - - public interface IContextMenu : IFeatures - { - List LoadContextMenus(Result selectedResult); - } - - /// - /// Represent plugins that support internationalization - /// - public interface IPluginI18n : IFeatures - { - string GetTranslatedPluginTitle(); - - string GetTranslatedPluginDescription(); - } - - public interface IResultUpdated : IFeatures - { - event ResultUpdatedEventHandler ResultsUpdated; - } - - public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); - - public class ResultUpdatedEventArgs : EventArgs - { - public List Results; - public Query Query; - public CancellationToken Token { get; init; } = default; - } -} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs deleted file mode 100644 index 043de9ac0..000000000 --- a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Threading.Tasks; - -namespace Flow.Launcher.Plugin -{ - /// - /// This interface is to indicate and allow plugins to asyncronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - public interface IAsyncReloadable : IFeatures - { - Task ReloadDataAsync(); - } -} diff --git a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IReloadable.cs deleted file mode 100644 index ef421f5b2..000000000 --- a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Flow.Launcher.Plugin -{ - /// - /// This interface is to indicate and allow plugins to synchronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - /// - /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface - /// - /// - public interface IReloadable : IFeatures - { - void ReloadData(); - } -} diff --git a/Flow.Launcher.Plugin/Interfaces/ISavable.cs b/Flow.Launcher.Plugin/Interfaces/ISavable.cs deleted file mode 100644 index 2d13eaa6e..000000000 --- a/Flow.Launcher.Plugin/Interfaces/ISavable.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Flow.Launcher.Plugin -{ - /// - /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, - /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, - /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow - /// - public interface ISavable : IFeatures - { - void Save(); - } -} \ No newline at end of file