-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
41 lines (39 loc) · 1.35 KB
/
Plugin.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MetricsAnalyzers;
namespace Plugins
{
public class Plugin : IPlugins
{
public IEnumerable<MetricAnalyzer> GetAnalyzers()
{
System.IO.FileInfo fi = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
string[] files = System.IO.Directory.GetFiles(fi.Directory.FullName, "*.dll");
List<MetricAnalyzer> result = new List<MetricAnalyzer>();
foreach (string file in files)
{
try
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(file);
foreach (Type t in assembly.ExportedTypes)
{
if (t.BaseType == typeof(MetricsAnalyzers.MetricAnalyzer))
{
result.Add((MetricAnalyzer)Activator.CreateInstance(t));
}
}
}
catch(Exception)
{
//This block needs to be empty
//because of result could be empty
//logging is not necessary.
}
}
return result;
}
}
}