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