Rev | Line | |
---|
[4486] | 1 |
|
---|
[4490] | 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.IO;
|
---|
| 5 | using System.Linq;
|
---|
| 6 | using System.Reflection;
|
---|
| 7 | using HeuristicLab.PluginInfrastructure;
|
---|
| 8 |
|
---|
[4512] | 9 | namespace HeuristicLab_33.Tests {
|
---|
[4486] | 10 | internal static class PluginLoader {
|
---|
[4490] | 11 | public const string AssemblyExtension = ".dll";
|
---|
| 12 | public static List<Assembly> pluginAssemblies;
|
---|
[4487] | 13 |
|
---|
[4490] | 14 | static PluginLoader() {
|
---|
[4508] | 15 | foreach (string path in Directory.EnumerateFiles(Environment.CurrentDirectory)
|
---|
[4490] | 16 | .Where(s => s.EndsWith(AssemblyExtension)))
|
---|
| 17 | Assembly.LoadFrom(path);
|
---|
[4487] | 18 |
|
---|
[4490] | 19 | pluginAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(IsPluginAssembly).ToList();
|
---|
| 20 | }
|
---|
[4487] | 21 |
|
---|
[4490] | 22 | private static bool IsPluginAssembly(Assembly assembly) {
|
---|
| 23 | return assembly.GetExportedTypes()
|
---|
| 24 | .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface).Any();
|
---|
| 25 | }
|
---|
[4486] | 26 | }
|
---|
| 27 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.