Changeset 37
- Timestamp:
- 03/04/08 15:16:51 (17 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure.GUI/ManagerForm.cs
r29 r37 310 310 allAvailablePlugins.ForEach(delegate(PluginDescription availablePlugin) { 311 311 List<PluginTag> oldPlugins = allTags.FindAll(delegate(PluginTag currentPlugin) { 312 return currentPlugin.PluginName == availablePlugin.Name && currentPlugin.State == (PluginState.Installed | PluginState.Disabled); 312 return currentPlugin.PluginName == availablePlugin.Name && 313 (currentPlugin.State & (PluginState.Installed | PluginState.Disabled)) !=0; 313 314 }); 314 315 … … 330 331 }); 331 332 332 if(currentPlugins.Count == 1) { 333 if(currentPlugins[0].PluginVersion < availablePlugin.Version) { 334 overrides.Add(availablePlugin); 335 } 333 if(currentPlugins.Count == 1 && currentPlugins[0].PluginVersion < availablePlugin.Version) { 334 overrides.Add(availablePlugin); 336 335 } 337 336 }); … … 584 583 585 584 private void UpdateActionButtons(PluginTag tag) { 586 587 585 publishButton.Enabled = (tag.State & PluginState.Installed) == PluginState.Installed; 588 586 installButton.Enabled = (tag.State & PluginState.Available) == PluginState.Available; … … 597 595 installMenuItem.Checked = installButton.Checked; 598 596 deleteMenuItem.Checked = deleteButton.Checked; 599 600 597 } 601 598 … … 634 631 return nodes; 635 632 } 636 637 638 639 633 private void DisplayPluginInfo(string pluginInformation) { 640 634 infoTextBox.Text = pluginInformation; 641 635 } 642 643 644 636 private void upgradeButton_Click(object sender, EventArgs args) { 645 637 try { … … 683 675 }); 684 676 } 685 686 687 677 private List<string> upgradedPlugins = new List<string>(); 688 678 private void OnPreUpgradePlugins() { … … 697 687 }); 698 688 } 699 700 689 private void OnPostUpgradePlugins() { 701 690 allTags.ForEach(delegate(PluginTag tag) { … … 706 695 upgradedPlugins.Clear(); 707 696 } 708 709 697 /// <summary> 710 698 /// Deletes all files in the directories cacheDir, backupDir, tempDir -
trunk/sources/HeuristicLab.PluginInfrastructure.GUI/PluginTag.cs
r29 r37 85 85 } 86 86 87 private string message; 88 public string Message { 89 get { return message; } 90 } 91 87 92 public List<PluginTag> hull = new List<PluginTag>(); 88 93 … … 94 99 this.pluginName = plugin.Name; 95 100 this.pluginVersion = plugin.Version; 101 this.message = plugin.Message; 96 102 pluginDetails = GeneratePluginDetails(plugin); 97 103 pluginDependencies = GeneratePluginDependencies(plugin); … … 125 131 dependents += dependentPlugin.Name + " (" + dependentPlugin.Version + ")\n"; 126 132 }); 127 return " plugin: " + plugin.Name + "\n" +133 return "Plugin: " + plugin.Name + "\n" + 128 134 "Version: " + plugin.Version + "\n\n" + 129 "Requires: \n" + dependencies + "\n" + 130 "Used by:\n" + dependents + "\n" + 131 "Files:\n" + filenames + "\n"; 135 (dependencies.Length != 0 ? "Requires: \n" + dependencies + "\n" : "") + 136 (dependents.Length != 0 ? "Used by:\n" + dependents + "\n" : "") + 137 (filenames.Length != 0 ? "Files:\n" + filenames + "\n" : "") + message; 138 ; 132 139 } 133 140 -
trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs
r29 r37 75 75 76 76 private IPlugin FindPlugin(PluginInfo plugin) { 77 return allPlugins[plugin]; 77 if(allPlugins.ContainsKey(plugin)) { 78 return allPlugins[plugin]; 79 } else return null; 78 80 } 79 81 … … 90 92 /// </summary> 91 93 internal void Init() { 92 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { return Assembly.ReflectionOnlyLoad(args.Name); }; 94 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { 95 try { 96 return Assembly.ReflectionOnlyLoad(args.Name); 97 } catch(FileLoadException ex) { 98 return null; 99 } 100 }; 93 101 allPlugins.Clear(); 94 102 disabledPlugins.Clear(); … … 150 158 } 151 159 } 152 } catch(FileNotFoundException) { 153 // when a referenced assembly cannot be loaded then ignore this assembly in the plugin discovery 160 } catch(FileNotFoundException ex) { 161 PluginInfo info = new PluginInfo(); 162 AssemblyName name = assembly.GetName(); 163 info.Name = name.Name; 164 info.Version = name.Version; 165 info.Assemblies.Add(assembly.FullName); 166 info.Files.Add(assembly.Location); 167 info.Message = "File not found: " + ex.FileName; 168 disabledPlugins.Add(info); 169 } catch(FileLoadException ex) { 170 PluginInfo info = new PluginInfo(); 171 AssemblyName name = assembly.GetName(); 172 info.Name = name.Name; 173 info.Version = name.Version; 174 info.Files.Add(assembly.Location); 175 info.Assemblies.Add(assembly.FullName); 176 info.Message = "Couldn't load file: " + ex.FileName; 177 disabledPlugins.Add(info); 154 178 } 155 179 } … … 208 232 PluginInfo info = new PluginInfo(); 209 233 info.Name = pluginName; 234 info.Version = t.Assembly.GetName().Version; 210 235 info.Assemblies = pluginAssemblies; 211 236 info.Files.AddRange(pluginFiles); … … 226 251 visitedDependencies.Clear(); 227 252 if(!CheckPluginDependencies(pluginInfo.Name)) { 253 PluginInfo matchingInfo = preloadedPluginInfos.Find(delegate(PluginInfo info) { return info.Name == pluginInfo.Name; }); 254 if(matchingInfo == null) throw new InvalidProgramException(); // shouldn't happen 255 foreach(string dependency in pluginDependencies[matchingInfo]) { 256 PluginInfo dependencyInfo = new PluginInfo(); 257 dependencyInfo.Name = dependency; 258 pluginInfo.Dependencies.Add(dependencyInfo); 259 } 260 261 pluginInfo.Message = "Disabled: missing plugin dependency."; 228 262 disabledPlugins.Add(pluginInfo); 229 263 } … … 325 359 foreach(PluginInfo plugin in preloadedPluginInfos) { 326 360 if(!CheckPluginFiles(plugin)) { 361 plugin.Message = "Disabled: missing plugin file."; 327 362 disabledPlugins.Add(plugin); 328 363 } … … 348 383 349 384 internal void OnDelete(PluginInfo pluginInfo) { 350 FindPlugin(pluginInfo).OnDelete(); 385 IPlugin plugin = FindPlugin(pluginInfo); 386 if(plugin!=null) plugin.OnDelete(); 351 387 } 352 388 353 389 internal void OnInstall(PluginInfo pluginInfo) { 354 FindPlugin(pluginInfo).OnInstall(); 390 IPlugin plugin = FindPlugin(pluginInfo); 391 if(plugin != null) plugin.OnInstall(); 355 392 } 356 393 357 394 internal void OnPreUpdate(PluginInfo pluginInfo) { 358 FindPlugin(pluginInfo).OnPreUpdate(); 395 IPlugin plugin = FindPlugin(pluginInfo); 396 if(plugin != null) plugin.OnPreUpdate(); 359 397 } 360 398 361 399 internal void OnPostUpdate(PluginInfo pluginInfo) { 362 FindPlugin(pluginInfo).OnPostUpdate(); 400 IPlugin plugin = FindPlugin(pluginInfo); 401 if(plugin != null) plugin.OnPostUpdate(); 363 402 } 364 403 } -
trunk/sources/HeuristicLab.PluginInfrastructure/PluginInfo.cs
r29 r37 68 68 } 69 69 70 71 private string message; 72 public string Message { 73 get { return message; } 74 set { message = value; } 75 } 76 70 77 public override string ToString() { 71 78 return Name;
Note: See TracChangeset
for help on using the changeset viewer.