Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/08/08 22:54:02 (15 years ago)
Author:
gkronber
Message:

created a branch for changes needed to run HL3 on Mono 2.0
(ticket #298)

Location:
branches/HL-3.2-MonoMigration
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HL-3.2-MonoMigration/HeuristicLab.PluginInfrastructure/PluginManager.cs

    r316 r638  
    2727  // must extend MarshalByRefObject because of event passing between Loader and PluginManager (each in it's own AppDomain)
    2828  public class PluginManager : MarshalByRefObject {
    29 
    3029    // singleton: only one manager allowed in each AppDomain
    31     private static PluginManager manager = new PluginManager();
     30    private static readonly PluginManager manager = PluginManager.manager==null?new PluginManager():PluginManager.manager;
     31    static PluginManager() { Console.WriteLine("static ctor called "); }
    3232    public static PluginManager Manager {
    33       get { return manager; }
     33      get {
     34        return manager;
     35      }
    3436    }
    3537
    36     // singleton: only one control manager allowed in each applicatoin (i.e. AppDomain)
     38    // singleton: only one control manager allowed in each application (i.e. AppDomain)
    3739    private static IControlManager controlManager;
    3840    public static IControlManager ControlManager {
     
    7173    private ICollection<PluginInfo> loadedPlugins;
    7274    public ICollection<PluginInfo> LoadedPlugins {
    73       get { return loadedPlugins; }
    74       internal set { loadedPlugins = value; }
     75      get {
     76        Console.WriteLine(AppDomain.CurrentDomain.Id);
     77        Console.WriteLine(this.GetHashCode());
     78        if(loadedPlugins != null) Console.WriteLine(loadedPlugins.Count); else Console.WriteLine("Loaded plugins==null!");
     79        return loadedPlugins;
     80      }
     81      internal set {
     82        Console.WriteLine(AppDomain.CurrentDomain.Id);
     83        Console.WriteLine(value.Count);
     84        Console.WriteLine(this.GetHashCode());
     85        loadedPlugins = new List<PluginInfo>(value);
     86      }
    7587    }
    7688
     
    8294      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
    8395      setup.PrivateBinPath = pluginDir;
    84       pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup);
     96      pluginDomain = AppDomain.CreateDomain("plugin domain");
     97      pluginDomain.SetupInformation.PrivateBinPath = pluginDir;
    8598      remoteLoader = (Loader)pluginDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure", "HeuristicLab.PluginInfrastructure.Loader");
    86       remoteLoader.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if(Action != null) Action(this, args); };
     99      remoteLoader.PluginAction += new PluginManagerActionEventHandler(remoteLoader_PluginAction);
    87100      remoteLoader.Init();
    88101      NotifyListeners(PluginManagerAction.Initialized, "-");
     102    }
     103
     104    public void remoteLoader_PluginAction(object sender, PluginManagerActionEventArgs e) {
     105      if(Action != null) Action(this, e);
    89106    }
    90107
     
    98115      // activate a PluginRunner instance in the application
    99116      // and remotely tell it to start the application
    100 
     117      Console.WriteLine(appInfo);
    101118      NotifyListeners(PluginManagerAction.Starting, appInfo.Name);
    102119      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
    103120      setup.PrivateBinPath = pluginDir;
    104       AppDomain applicationDomain = AppDomain.CreateDomain(appInfo.Name + " AppDomain", null, setup);
     121      AppDomain applicationDomain = AppDomain.CreateDomain(appInfo.Name + " AppDomain");
     122      applicationDomain.SetupInformation.PrivateBinPath = pluginDir;
    105123      try {
    106124        Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfrastructure", "HeuristicLab.PluginInfrastructure.Runner");
     
    108126        remoteRunner.LoadPlugins(remoteLoader.ActivePlugins);
    109127        NotifyListeners(PluginManagerAction.Initialized, "All plugins");
    110         remoteRunner.Run(appInfo);
     128        remoteRunner.Run(appInfo.PluginAssembly, appInfo.PluginType);
    111129      } finally {
    112130        // make sure domain is unloaded in all cases
Note: See TracChangeset for help on using the changeset viewer.