@@ -42,11 +42,11 @@ private PluginManager()
42
42
43
43
internal IViewer DefaultPlugin { get ; } = new Plugin . InfoPanel . Plugin ( ) ;
44
44
45
- internal List < IViewer > LoadedPlugins { get ; private set ; } = new List < IViewer > ( ) ;
45
+ internal List < IViewer > LoadedPlugins { get ; private set ; } = [ ] ;
46
46
47
47
internal static PluginManager GetInstance ( )
48
48
{
49
- return _instance ?? ( _instance = new PluginManager ( ) ) ;
49
+ return _instance ??= new PluginManager ( ) ;
50
50
}
51
51
52
52
internal IViewer FindMatch ( string path )
@@ -86,34 +86,32 @@ private void LoadPlugins(string folder)
86
86
87
87
var failedPlugins = new List < ( string Plugin , Exception Error ) > ( ) ;
88
88
89
- Directory . GetFiles ( folder , "QuickLook.Plugin.*.dll" ,
90
- SearchOption . AllDirectories )
89
+ Directory . GetFiles ( folder , "QuickLook.Plugin.*.dll" , SearchOption . AllDirectories )
91
90
. ToList ( )
92
- . ForEach (
93
- lib =>
94
- {
95
- try
96
- {
97
- ( from t in Assembly . LoadFrom ( lib ) . GetExportedTypes ( )
98
- where ! t . IsInterface && ! t . IsAbstract
99
- where typeof ( IViewer ) . IsAssignableFrom ( t )
100
- select t ) . ToList ( )
101
- . ForEach ( type => LoadedPlugins . Add ( type . CreateInstance < IViewer > ( ) ) ) ;
102
- }
103
- // 0x80131515: ERROR_ASSEMBLY_FILE_BLOCKED - Windows blocked the assembly due to security policy
104
- catch ( FileLoadException ex ) when ( ex . HResult == unchecked ( ( int ) 0x80131515 ) && SettingHelper . IsPortableVersion ( ) )
105
- {
106
- if ( ! HandleSecurityBlockedException ( ) ) throw ;
107
- }
108
- catch ( Exception ex )
109
- {
110
- // Log the error
111
- ProcessHelper . WriteLog ( $ "Failed to load plugin { Path . GetFileName ( lib ) } : { ex } ") ;
112
- failedPlugins . Add ( ( Path . GetFileName ( lib ) , ex ) ) ;
113
- }
114
- } ) ;
115
-
116
- LoadedPlugins = LoadedPlugins . OrderByDescending ( i => i . Priority ) . ToList ( ) ;
91
+ . ForEach ( lib =>
92
+ {
93
+ try
94
+ {
95
+ ( from t in Assembly . LoadFrom ( lib ) . GetExportedTypes ( )
96
+ where ! t . IsInterface && ! t . IsAbstract
97
+ where typeof ( IViewer ) . IsAssignableFrom ( t )
98
+ select t ) . ToList ( )
99
+ . ForEach ( type => LoadedPlugins . Add ( type . CreateInstance < IViewer > ( ) ) ) ;
100
+ }
101
+ // 0x80131515: ERROR_ASSEMBLY_FILE_BLOCKED - Windows blocked the assembly due to security policy
102
+ catch ( FileLoadException ex ) when ( ex . HResult == unchecked ( ( int ) 0x80131515 ) && SettingHelper . IsPortableVersion ( ) )
103
+ {
104
+ if ( ! HandleSecurityBlockedException ( ) ) throw ;
105
+ }
106
+ catch ( Exception ex )
107
+ {
108
+ // Log the error
109
+ ProcessHelper . WriteLog ( $ "Failed to load plugin { Path . GetFileName ( lib ) } : { ex } ") ;
110
+ failedPlugins . Add ( ( Path . GetFileName ( lib ) , ex ) ) ;
111
+ }
112
+ } ) ;
113
+
114
+ LoadedPlugins = [ .. LoadedPlugins . OrderByDescending ( i => i . Priority ) ] ;
117
115
118
116
// If any plugins failed to load, show a message box with the details
119
117
if ( failedPlugins . Any ( ) )
0 commit comments