Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/02/09 14:14:47 (15 years ago)
Author:
gkronber
Message:
  • Refactoring: renamed method LoadPlugins to LoadAssemblies in class Runner.
  • Added cache of loaded assemblies in the Runner.
  • Added an AssemblyResolveEvent that returns already loaded assemblies from the cache.

#658 (For the execution of jobs assemblies have to be loaded dynamically in the correct order)

Location:
trunk/sources/HeuristicLab.PluginInfrastructure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs

    r1936 r1990  
    229229
    230230      if (assemblyFiles != null && assemblyFiles.Count > 0)
    231         remoteRunner.LoadPlugins(assemblyFiles);
     231        remoteRunner.LoadAssemblies(assemblyFiles);
    232232     
    233233      //if (depPlugins != null && depPlugins.Count > 0) {       
  • trunk/sources/HeuristicLab.PluginInfrastructure/Runner.cs

    r1936 r1990  
    3030  public class Runner : MarshalByRefObject {
    3131
     32    private Dictionary<string, Assembly> loadedAssemblies;
     33
     34    public Runner() {
     35      loadedAssemblies = new Dictionary<string, Assembly>();
     36      AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
     37        if(loadedAssemblies.ContainsKey(args.Name)) {
     38          return loadedAssemblies[args.Name];
     39        }
     40        return null;
     41      };
     42    }
     43
    3244    public void LoadPlugins(ICollection<PluginInfo> plugins) {
    3345      //FileIOPermission fileperm = new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\Program Files\HeuristicLab 3.0\plugins\");
     
    4355    }
    4456    /// <summary>
    45     /// Loads plugins from a byte array
     57    /// Loads assemblies from a byte array
    4658    /// </summary>
    47     /// <param name="plugins">bytearray of all plugins that should be loaded</param>
    48     public void LoadPlugins(ICollection<byte[]> plugins) {
    49       foreach (byte[] plugin in plugins) {
    50         Assembly.Load(plugin);       
     59    /// <param name="plugins">bytearray of all assemblies that should be loaded</param>
     60    public void LoadAssemblies(ICollection<byte[]> assemblies) {
     61      foreach (byte[] asm in assemblies) {
     62        Assembly loadedAsm = Assembly.Load(asm);
     63        RegisterLoadedAssembly(loadedAsm);
    5164      }
     65    }
     66
     67    private void RegisterLoadedAssembly(Assembly asm) {
     68      loadedAssemblies.Add(asm.FullName, asm);
     69      loadedAssemblies.Add(asm.GetName().Name, asm); // add short name
    5270    }
    5371
Note: See TracChangeset for help on using the changeset viewer.