@@ -24,14 +24,13 @@ public class PluginRegistry
2424
2525 private static readonly ILogger _logger = LogManager . GetCurrentClassLogger ( ) ;
2626
27- private static readonly object lockObject = new object ( ) ;
28- private static PluginRegistry instance = null ;
27+ private static readonly object _lockObject = new object ( ) ;
28+ private static PluginRegistry _instance ;
2929
30- private readonly IFileSystemCallback fileSystemCallback = new FileSystemCallback ( ) ;
31- private readonly IList < ILogExpertPlugin > pluginList = new List < ILogExpertPlugin > ( ) ;
30+ private readonly IFileSystemCallback _fileSystemCallback = new FileSystemCallback ( ) ;
31+ private readonly IList < ILogExpertPlugin > _pluginList = new List < ILogExpertPlugin > ( ) ;
3232
33- private readonly IDictionary < string , IKeywordAction > registeredKeywordsDict =
34- new Dictionary < string , IKeywordAction > ( ) ;
33+ private readonly IDictionary < string , IKeywordAction > _registeredKeywordsDict = new Dictionary < string , IKeywordAction > ( ) ;
3534
3635 #endregion
3736
@@ -60,14 +59,14 @@ private PluginRegistry()
6059
6160 public static PluginRegistry GetInstance ( )
6261 {
63- lock ( lockObject )
62+ lock ( _lockObject )
6463 {
65- if ( instance == null )
64+ if ( _instance == null )
6665 {
67- instance = new PluginRegistry ( ) ;
66+ _instance = new PluginRegistry ( ) ;
6867 }
6968
70- return instance ;
69+ return _instance ;
7170 }
7271 }
7372
@@ -78,16 +77,19 @@ public static PluginRegistry GetInstance()
7877 internal void LoadPlugins ( )
7978 {
8079 _logger . Info ( "Loading plugins..." ) ;
81- this . RegisteredColumnizers = new List < ILogLineColumnizer > ( ) ;
82- this . RegisteredColumnizers . Add ( new DefaultLogfileColumnizer ( ) ) ;
83- this . RegisteredColumnizers . Add ( new TimestampColumnizer ( ) ) ;
84- this . RegisteredColumnizers . Add ( new SquareBracketColumnizer ( ) ) ;
85- this . RegisteredColumnizers . Add ( new ClfColumnizer ( ) ) ;
86- this . RegisteredFileSystemPlugins . Add ( new LocalFileSystem ( ) ) ;
80+
81+ RegisteredColumnizers = new List < ILogLineColumnizer > ( ) ;
82+ RegisteredColumnizers . Add ( new DefaultLogfileColumnizer ( ) ) ;
83+ RegisteredColumnizers . Add ( new TimestampColumnizer ( ) ) ;
84+ RegisteredColumnizers . Add ( new SquareBracketColumnizer ( ) ) ;
85+ RegisteredColumnizers . Add ( new ClfColumnizer ( ) ) ;
86+ RegisteredFileSystemPlugins . Add ( new LocalFileSystem ( ) ) ;
8787
8888 string pluginDir = Application . StartupPath + Path . DirectorySeparatorChar + "plugins" ;
89+
8990 AppDomain currentDomain = AppDomain . CurrentDomain ;
90- currentDomain . AssemblyResolve += new ResolveEventHandler ( ColumnizerResolveEventHandler ) ;
91+ currentDomain . AssemblyResolve += ColumnizerResolveEventHandler ;
92+
9193 if ( Directory . Exists ( pluginDir ) )
9294 {
9395 string [ ] dllNames = Directory . GetFiles ( pluginDir , "*.dll" ) ;
@@ -119,16 +121,17 @@ internal void LoadPlugins()
119121 if ( cti != null )
120122 {
121123 object o = cti . Invoke ( new object [ ] { } ) ;
122- this . RegisteredColumnizers . Add ( ( ILogLineColumnizer ) o ) ;
123- if ( o is IColumnizerConfigurator )
124+ RegisteredColumnizers . Add ( ( ILogLineColumnizer ) o ) ;
125+
126+ if ( o is IColumnizerConfigurator configurator )
124127 {
125- ( ( IColumnizerConfigurator ) o ) . LoadConfig ( ConfigManager . ConfigDir ) ;
128+ configurator . LoadConfig ( ConfigManager . Settings . preferences . PortableMode ? ConfigManager . PortableModeDir : ConfigManager . ConfigDir ) ;
126129 }
127130
128- if ( o is ILogExpertPlugin )
131+ if ( o is ILogExpertPlugin plugin )
129132 {
130- this . pluginList . Add ( o as ILogExpertPlugin ) ;
131- ( o as ILogExpertPlugin ) . PluginLoaded ( ) ;
133+ _pluginList . Add ( plugin ) ;
134+ plugin . PluginLoaded ( ) ;
132135 }
133136
134137 _logger . Info ( "Added columnizer {0}" , type . Name ) ;
@@ -188,13 +191,13 @@ internal void LoadPlugins()
188191 internal IKeywordAction FindKeywordActionPluginByName ( string name )
189192 {
190193 IKeywordAction action = null ;
191- this . registeredKeywordsDict . TryGetValue ( name , out action ) ;
194+ _registeredKeywordsDict . TryGetValue ( name , out action ) ;
192195 return action ;
193196 }
194197
195198 internal void CleanupPlugins ( )
196199 {
197- foreach ( ILogExpertPlugin plugin in this . pluginList )
200+ foreach ( ILogExpertPlugin plugin in _pluginList )
198201 {
199202 plugin . AppExiting ( ) ;
200203 }
@@ -207,7 +210,7 @@ internal IFileSystemPlugin FindFileSystemForUri(string uriString)
207210 _logger . Debug ( "Trying to find file system plugin for uri {0}" , uriString ) ;
208211 }
209212
210- foreach ( IFileSystemPlugin fs in this . RegisteredFileSystemPlugins )
213+ foreach ( IFileSystemPlugin fs in RegisteredFileSystemPlugins )
211214 {
212215 if ( _logger . IsDebugEnabled )
213216 {
@@ -238,15 +241,15 @@ private bool TryAsContextMenu(Type type)
238241 IContextMenuEntry me = TryInstantiate < IContextMenuEntry > ( type ) ;
239242 if ( me != null )
240243 {
241- this . RegisteredContextMenuPlugins . Add ( me ) ;
244+ RegisteredContextMenuPlugins . Add ( me ) ;
242245 if ( me is ILogExpertPluginConfigurator )
243246 {
244247 ( ( ILogExpertPluginConfigurator ) me ) . LoadConfig ( ConfigManager . ConfigDir ) ;
245248 }
246249
247250 if ( me is ILogExpertPlugin )
248251 {
249- this . pluginList . Add ( me as ILogExpertPlugin ) ;
252+ _pluginList . Add ( me as ILogExpertPlugin ) ;
250253 ( me as ILogExpertPlugin ) . PluginLoaded ( ) ;
251254 }
252255
@@ -262,16 +265,16 @@ private bool TryAsKeywordAction(Type type)
262265 IKeywordAction ka = TryInstantiate < IKeywordAction > ( type ) ;
263266 if ( ka != null )
264267 {
265- this . RegisteredKeywordActions . Add ( ka ) ;
266- this . registeredKeywordsDict . Add ( ka . GetName ( ) , ka ) ;
268+ RegisteredKeywordActions . Add ( ka ) ;
269+ _registeredKeywordsDict . Add ( ka . GetName ( ) , ka ) ;
267270 if ( ka is ILogExpertPluginConfigurator )
268271 {
269272 ( ( ILogExpertPluginConfigurator ) ka ) . LoadConfig ( ConfigManager . ConfigDir ) ;
270273 }
271274
272275 if ( ka is ILogExpertPlugin )
273276 {
274- this . pluginList . Add ( ka as ILogExpertPlugin ) ;
277+ _pluginList . Add ( ka as ILogExpertPlugin ) ;
275278 ( ka as ILogExpertPlugin ) . PluginLoaded ( ) ;
276279 }
277280
@@ -285,23 +288,23 @@ private bool TryAsKeywordAction(Type type)
285288 private bool TryAsFileSystem ( Type type )
286289 {
287290 // file system plugins can have optional constructor with IFileSystemCallback argument
288- IFileSystemPlugin fs = TryInstantiate < IFileSystemPlugin > ( type , this . fileSystemCallback ) ;
291+ IFileSystemPlugin fs = TryInstantiate < IFileSystemPlugin > ( type , _fileSystemCallback ) ;
289292 if ( fs == null )
290293 {
291294 fs = TryInstantiate < IFileSystemPlugin > ( type ) ;
292295 }
293296
294297 if ( fs != null )
295298 {
296- this . RegisteredFileSystemPlugins . Add ( fs ) ;
299+ RegisteredFileSystemPlugins . Add ( fs ) ;
297300 if ( fs is ILogExpertPluginConfigurator )
298301 {
299302 ( ( ILogExpertPluginConfigurator ) fs ) . LoadConfig ( ConfigManager . ConfigDir ) ;
300303 }
301304
302305 if ( fs is ILogExpertPlugin )
303306 {
304- this . pluginList . Add ( fs as ILogExpertPlugin ) ;
307+ _pluginList . Add ( fs as ILogExpertPlugin ) ;
305308 ( fs as ILogExpertPlugin ) . PluginLoaded ( ) ;
306309 }
307310
0 commit comments