Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab/3.3/Tests/PluginLoader.cs @ 5304

Last change on this file since 5304 was 5272, checked in by mkommend, 14 years ago

Corrected TestAssemblyExtension in PluginLoader (ticket #1351).

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