4
4
using System . Dynamic ;
5
5
using System . IO ;
6
6
using System . Linq ;
7
+ using System . Runtime . Remoting ;
7
8
using System . Threading ;
8
9
using System . Threading . Tasks ;
9
10
using System . Timers ;
@@ -215,7 +216,7 @@ private void DetectPlugins()
215
216
{
216
217
var def = AssemblyDefinition . ReadAssembly ( info . FullName ) ;
217
218
218
- var it = def . MainModule . Types . Where ( e => e . Interfaces . Any ( r => ( r . FullName == typeof ( ICheck ) . FullName ) ) || ( e . Interfaces . Any ( r => r . FullName == typeof ( ILongRunningMetricProvider ) . FullName ) ) ) . ToList ( ) ;
219
+ var it = def . MainModule . Types . Where ( e => e . Interfaces . Any ( r => ( r . FullName == typeof ( IMetricProvider ) . FullName ) ) || ( e . Interfaces . Any ( r => r . FullName == typeof ( ILongRunningMetricProvider ) . FullName ) ) ) . ToList ( ) ;
219
220
220
221
var isPlugin = false ;
221
222
@@ -225,20 +226,6 @@ private void DetectPlugins()
225
226
ICheckTypeList . Add ( res ) ;
226
227
isPlugin = true ;
227
228
}
228
-
229
- //var typeDefinitions = def.MainModule.Types.Where(f=> f.CustomAttributes.Any(a=>a.AttributeType.FullName == typeof(PerformanceCounterGroupingAttribute).FullName ) ).ToList();
230
-
231
- //if (typeDefinitions.Any())
232
- //{
233
- // logger.Trace($"Found slice {info.FullName}");
234
-
235
- // var loadSlices = instanceProxy.LoadSlices(info.FullName);
236
-
237
- // sliceCheckList.Add(loadSlices);
238
-
239
- // isPlugin = true;
240
- // }
241
-
242
229
243
230
if ( isPlugin )
244
231
{
@@ -253,13 +240,16 @@ private void DetectPlugins()
253
240
}
254
241
}
255
242
256
- var checkNames = ICheckTypeList . Select ( e => e . GetType ( ) . FullName ) . ToList ( ) ;
243
+ var checkNames = ICheckTypeList . ToList ( ) ;
257
244
258
245
foreach ( var jsonFiles in workingFiles . GetFiles ( "*.json" ) )
259
246
{
260
- if ( checkNames . Contains ( Path . GetFileNameWithoutExtension ( jsonFiles . Name ) ) )
247
+ var filename = Path . GetFileNameWithoutExtension ( jsonFiles . Name ) ;
248
+ if ( checkNames . Contains ( filename ) )
261
249
{
262
- instanceProxy . PluginSettings . Add ( Path . GetFileNameWithoutExtension ( jsonFiles . Name ) , JObject . Parse ( File . ReadAllText ( jsonFiles . FullName ) ) as dynamic ) ;
250
+
251
+ //instanceProxy.PluginSettings.Add(filename, value);
252
+ instanceProxy . AddSettings ( filename , File . ReadAllText ( jsonFiles . FullName ) ) ;
263
253
}
264
254
}
265
255
@@ -274,7 +264,7 @@ private void DetectPlugins()
274
264
watcher . Renamed += delegate { pluginChangeDetected = true ; } ;
275
265
watcher . EnableRaisingEvents = true ;
276
266
277
- logger . Trace ( "Plugins found! " ) ;
267
+ logger . Trace ( "Plugin Load Complete " ) ;
278
268
}
279
269
FileSystemWatcher watcher ;
280
270
ExpandoObjectConverter eoConverter = new ExpandoObjectConverter ( ) ;
@@ -335,7 +325,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
335
325
return ;
336
326
}
337
327
338
- pluginCollection . Add ( result ) ;
328
+ pluginCollection . AddRange ( result ) ;
339
329
340
330
}
341
331
catch ( Exception ex )
@@ -348,7 +338,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
348
338
349
339
logger . Info ( "Polling long checks" ) ;
350
340
351
- try
341
+ try
352
342
{
353
343
var longRunningChecks = instanceProxy . GetLongRunningChecks ( ) ;
354
344
@@ -363,6 +353,11 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
363
353
364
354
}
365
355
}
356
+ catch ( RemotingException remoting )
357
+ {
358
+ logger . Warn ( "Remoting exception, will reload plugins" , remoting ) ;
359
+ pluginChangeDetected = true ;
360
+ }
366
361
catch ( Exception exception )
367
362
{
368
363
logger . Warn ( exception , "Error on polling for long checks" ) ;
0 commit comments