Changeset 766 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 11/15/08 22:08:33 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs
r316 r766 84 84 pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup); 85 85 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); }; 87 87 remoteLoader.Init(); 88 88 NotifyListeners(PluginManagerAction.Initialized, "-"); … … 100 100 101 101 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) { 102 120 AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation; 103 121 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) { 108 126 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); 114 129 } 130 NotifyListeners(PluginManagerAction.Initialized, "All plugins"); 131 return applicationDomain; 115 132 } 133 116 134 117 135 /// <summary> … … 122 140 public List<PluginInfo> GetDependentPlugins(PluginInfo pluginInfo) { 123 141 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)) { 127 145 mergedList.Add(plugin); 128 146 } … … 130 148 // make sure that only one entry for each plugin is added to the merged list 131 149 GetDependentPlugins(plugin).ForEach(delegate(PluginInfo dependentPlugin) { 132 if (!mergedList.Contains(dependentPlugin)) {150 if (!mergedList.Contains(dependentPlugin)) { 133 151 mergedList.Add(dependentPlugin); 134 152 } … … 164 182 165 183 private void NotifyListeners(PluginManagerAction action, string text) { 166 if (Action != null) {184 if (Action != null) { 167 185 Action(this, new PluginManagerActionEventArgs(text, action)); 168 186 }
Note: See TracChangeset
for help on using the changeset viewer.