-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathIPlugin.cs
42 lines (38 loc) · 1.33 KB
/
IPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Synchronous Plugin Model for Flow Launcher
/// <para>
/// If the Querying or Init method requires high IO transmission
/// or performaing CPU intense jobs (performing better with cancellation), please try the IAsyncPlugin interface
/// </para>
/// </summary>
public interface IPlugin : IAsyncPlugin
{
/// <summary>
/// Querying when user's search changes
/// <para>
/// This method will be called within a Task.Run,
/// so please avoid synchrously wait for long.
/// </para>
/// </summary>
/// <param name="query">Query to search</param>
/// <returns></returns>
List<Result> Query(Query query);
/// <summary>
/// Initialize plugin
/// </summary>
/// <param name="context"></param>
void Init(PluginInitContext context);
async Task IAsyncPlugin.InitAsync(PluginInitContext context)
{
// Some plugins should not be initialized in task
Init(context);
await Task.CompletedTask;
}
Task<List<Result>> IAsyncPlugin.QueryAsync(Query query, CancellationToken token) => Task.Run(() => Query(query));
}
}