Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4767 was 4512, checked in by swagner, 14 years ago

Reorganized unit test for GeneticAlgorithm (#1212)

File size: 878 bytes
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";
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.