Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/08 22:08:33 (16 years ago)
Author:
gkronber
Message:

fixed #362 (GridClient doesn't work since the change to use major.minor version-numbers for plugins)

File:
1 edited

Legend:

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

    r316 r766  
    8484      pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup);
    8585      remoteLoader = (Loader)pluginDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure", "HeuristicLab.PluginInfrastructure.Loader");
    86       remoteLoader.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if(Action != null) Action(this, args); };
     86      remoteLoader.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if (Action != null) Action(this, args); };
    8787      remoteLoader.Init();
    8888      NotifyListeners(PluginManagerAction.Initialized, "-");
     
    100100
    101101      NotifyListeners(PluginManagerAction.Starting, appInfo.Name);
     102      AppDomain applicationDomain = null;
     103      try {
     104        applicationDomain = CreateAndInitAppDomain(appInfo.Name + " AppDomain");
     105        Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap(typeof(Runner).Assembly.GetName().Name, typeof(Runner).FullName);
     106        remoteRunner.Run(appInfo);
     107      }
     108      finally {
     109        // make sure domain is unloaded in all cases
     110        if (applicationDomain != null) AppDomain.Unload(applicationDomain);
     111      }
     112    }
     113
     114    /// <summary>
     115    /// Creates a new AppDomain with all plugins preloaded.
     116    /// </summary>
     117    /// <param name="friendlyName">Name of the new AppDomain</param>
     118    /// <returns>the new AppDomain with all plugins preloaded.</returns>
     119    public AppDomain CreateAndInitAppDomain(string friendlyName) {
    102120      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
    103121      setup.PrivateBinPath = pluginDir;
    104       AppDomain applicationDomain = AppDomain.CreateDomain(appInfo.Name + " AppDomain", null, setup);
    105       try {
    106         Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfrastructure", "HeuristicLab.PluginInfrastructure.Runner");
    107         NotifyListeners(PluginManagerAction.Initializing, "All plugins");
     122      AppDomain applicationDomain = AppDomain.CreateDomain(friendlyName, null, setup);
     123      Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap(typeof(Runner).Assembly.GetName().Name, typeof(Runner).FullName);
     124      NotifyListeners(PluginManagerAction.Initializing, "All plugins");
     125      if (remoteLoader != null) {
    108126        remoteRunner.LoadPlugins(remoteLoader.ActivePlugins);
    109         NotifyListeners(PluginManagerAction.Initialized, "All plugins");
    110         remoteRunner.Run(appInfo);
    111       } finally {
    112         // make sure domain is unloaded in all cases
    113         AppDomain.Unload(applicationDomain);
     127      } else if (LoadedPlugins != null && LoadedPlugins.Count > 0) {
     128        remoteRunner.LoadPlugins(LoadedPlugins);
    114129      }
     130      NotifyListeners(PluginManagerAction.Initialized, "All plugins");
     131      return applicationDomain;
    115132    }
     133
    116134
    117135    /// <summary>
     
    122140    public List<PluginInfo> GetDependentPlugins(PluginInfo pluginInfo) {
    123141      List<PluginInfo> mergedList = new List<PluginInfo>();
    124       foreach(PluginInfo plugin in InstalledPlugins) {
    125         if(plugin.Dependencies.Contains(pluginInfo)) {
    126           if(!mergedList.Contains(plugin)) {
     142      foreach (PluginInfo plugin in InstalledPlugins) {
     143        if (plugin.Dependencies.Contains(pluginInfo)) {
     144          if (!mergedList.Contains(plugin)) {
    127145            mergedList.Add(plugin);
    128146          }
     
    130148          // make sure that only one entry for each plugin is added to the merged list
    131149          GetDependentPlugins(plugin).ForEach(delegate(PluginInfo dependentPlugin) {
    132             if(!mergedList.Contains(dependentPlugin)) {
     150            if (!mergedList.Contains(dependentPlugin)) {
    133151              mergedList.Add(dependentPlugin);
    134152            }
     
    164182
    165183    private void NotifyListeners(PluginManagerAction action, string text) {
    166       if(Action != null) {
     184      if (Action != null) {
    167185        Action(this, new PluginManagerActionEventArgs(text, action));
    168186      }
Note: See TracChangeset for help on using the changeset viewer.