6
6
using System . Text ;
7
7
using System . Threading . Tasks ;
8
8
using Microsoft . Win32 ;
9
- using Flow . Launcher . Infrastructure ;
10
9
using Flow . Launcher . Plugin . Program . Logger ;
11
10
using Flow . Launcher . Plugin . SharedCommands ;
12
11
using Flow . Launcher . Plugin . SharedModels ;
@@ -73,7 +72,7 @@ public string UniqueIdentifier
73
72
private const string ExeExtension = "exe" ;
74
73
private string _uid = string . Empty ;
75
74
76
- private static readonly Win32 Default = new Win32 ( )
75
+ private static readonly Win32 Default = new ( )
77
76
{
78
77
Name = string . Empty ,
79
78
Description = string . Empty ,
@@ -92,7 +91,7 @@ private static MatchResult Match(string query, IReadOnlyCollection<string> candi
92
91
if ( candidates . Count == 0 )
93
92
return null ;
94
93
95
- var match = candidates . Select ( candidate => StringMatcher . FuzzySearch ( query , candidate ) )
94
+ var match = candidates . Select ( candidate => Main . Context . API . FuzzySearch ( query , candidate ) )
96
95
. MaxBy ( match => match . Score ) ;
97
96
98
97
return match ? . IsSearchPrecisionScoreMet ( ) ?? false ? match : null ;
@@ -112,14 +111,14 @@ public Result Result(string query, IPublicAPI api)
112
111
resultName . Equals ( Description ) )
113
112
{
114
113
title = resultName ;
115
- matchResult = StringMatcher . FuzzySearch ( query , resultName ) ;
114
+ matchResult = Main . Context . API . FuzzySearch ( query , resultName ) ;
116
115
}
117
116
else
118
117
{
119
118
// Search in both
120
119
title = $ "{ resultName } : { Description } ";
121
- var nameMatch = StringMatcher . FuzzySearch ( query , resultName ) ;
122
- var descriptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
120
+ var nameMatch = Main . Context . API . FuzzySearch ( query , resultName ) ;
121
+ var descriptionMatch = Main . Context . API . FuzzySearch ( query , Description ) ;
123
122
if ( descriptionMatch . Score > nameMatch . Score )
124
123
{
125
124
for ( int i = 0 ; i < descriptionMatch . MatchData . Count ; i ++ )
@@ -219,27 +218,27 @@ public List<Result> ContextMenus(IPublicAPI api)
219
218
{
220
219
var contextMenus = new List < Result >
221
220
{
222
- new Result
221
+ new ( )
223
222
{
224
223
Title = api . GetTranslation ( "flowlauncher_plugin_program_run_as_different_user" ) ,
225
- Action = _ =>
224
+ Action = c =>
226
225
{
227
226
var info = new ProcessStartInfo
228
227
{
229
228
FileName = FullPath , WorkingDirectory = ParentDirectory , UseShellExecute = true
230
229
} ;
231
230
232
- Task . Run ( ( ) => Main . StartProcess ( ShellCommand . RunAsDifferentUser , info ) ) ;
231
+ _ = Task . Run ( ( ) => Main . StartProcess ( ShellCommand . RunAsDifferentUser , info ) ) ;
233
232
234
233
return true ;
235
234
} ,
236
235
IcoPath = "Images/user.png" ,
237
236
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7ee " ) ,
238
237
} ,
239
- new Result
238
+ new ( )
240
239
{
241
240
Title = api . GetTranslation ( "flowlauncher_plugin_program_run_as_administrator" ) ,
242
- Action = _ =>
241
+ Action = c =>
243
242
{
244
243
var info = new ProcessStartInfo
245
244
{
@@ -249,14 +248,14 @@ public List<Result> ContextMenus(IPublicAPI api)
249
248
UseShellExecute = true
250
249
} ;
251
250
252
- Task . Run ( ( ) => Main . StartProcess ( Process . Start , info ) ) ;
251
+ _ = Task . Run ( ( ) => Main . StartProcess ( Process . Start , info ) ) ;
253
252
254
253
return true ;
255
254
} ,
256
255
IcoPath = "Images/cmd.png" ,
257
256
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7ef " ) ,
258
257
} ,
259
- new Result
258
+ new ( )
260
259
{
261
260
Title = api . GetTranslation ( "flowlauncher_plugin_program_open_containing_folder" ) ,
262
261
Action = _ =>
@@ -296,7 +295,7 @@ public override string ToString()
296
295
return Name ;
297
296
}
298
297
299
- private static List < FileSystemWatcher > Watchers = new List < FileSystemWatcher > ( ) ;
298
+ private static readonly List < FileSystemWatcher > Watchers = new ( ) ;
300
299
301
300
private static Win32 Win32Program ( string path )
302
301
{
@@ -402,7 +401,7 @@ private static Win32 UrlProgram(string path, string[] protocols)
402
401
var data = parser . ReadFile ( path ) ;
403
402
var urlSection = data [ "InternetShortcut" ] ;
404
403
var url = urlSection ? [ "URL" ] ;
405
- if ( String . IsNullOrEmpty ( url ) )
404
+ if ( string . IsNullOrEmpty ( url ) )
406
405
{
407
406
return program ;
408
407
}
@@ -418,12 +417,12 @@ private static Win32 UrlProgram(string path, string[] protocols)
418
417
}
419
418
420
419
var iconPath = urlSection ? [ "IconFile" ] ;
421
- if ( ! String . IsNullOrEmpty ( iconPath ) )
420
+ if ( ! string . IsNullOrEmpty ( iconPath ) )
422
421
{
423
422
program . IcoPath = iconPath ;
424
423
}
425
424
}
426
- catch ( Exception e )
425
+ catch ( Exception )
427
426
{
428
427
// Many files do not have the required fields, so no logging is done.
429
428
}
@@ -474,7 +473,7 @@ private static string Extension(string path)
474
473
var extension = Path . GetExtension ( path ) ? . ToLowerInvariant ( ) ;
475
474
if ( ! string . IsNullOrEmpty ( extension ) )
476
475
{
477
- return extension . Substring ( 1 ) ; // remove dot
476
+ return extension [ 1 .. ] ; // remove dot
478
477
}
479
478
else
480
479
{
@@ -785,7 +784,7 @@ public static void WatchProgramUpdate(Settings settings)
785
784
_ = Task . Run ( MonitorDirectoryChangeAsync ) ;
786
785
}
787
786
788
- private static Channel < byte > indexQueue = Channel . CreateBounded < byte > ( 1 ) ;
787
+ private static readonly Channel < byte > indexQueue = Channel . CreateBounded < byte > ( 1 ) ;
789
788
790
789
public static async Task MonitorDirectoryChangeAsync ( )
791
790
{
0 commit comments