Changeset 8 for trunk/sources
- Timestamp:
- 02/20/08 11:08:04 (17 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure.GUI/ManagerForm.cs
r2 r8 111 111 112 112 private void publishButton_Click(object sender, EventArgs args) { 113 Trace.Assert(pluginTreeView.SelectedNode.Tag is PluginTag);114 113 115 114 PluginInfo plugin = ((PluginTag)pluginTreeView.SelectedNode.Tag).Plugin; … … 235 234 return tag.PluginName == upgrade.Name; 236 235 }); 237 // only one plugin must be found238 Trace.Assert(oldPlugins.Count == 1);239 236 PluginTag oldPlugin = oldPlugins[0]; 240 241 // the plugin must be installed already242 Trace.Assert(oldPlugin.State == PluginState.Installed);243 // the old plugin has to have an older version than the upgrade244 Trace.Assert(oldPlugin.PluginVersion < upgrade.Version);245 237 246 238 // store the upgrade in the old plugin … … 255 247 }); 256 248 257 // only one plugin must be found258 Trace.Assert(currentPlugins.Count == 1);259 249 PluginTag currentPlugin = currentPlugins[0]; 260 261 // the plugin must be available already262 Trace.Assert(currentPlugin.State == PluginState.Available);263 // the old plugin has to have an older version than the overriding plugin264 Trace.Assert(currentPlugin.PluginVersion < overridingPlugin.Version);265 250 266 251 // replace the plugin description of the available plugin to point to the overriding plugin … … 333 318 }); 334 319 335 // either none or exactly one plugin to upgrade can be found336 Trace.Assert(oldPlugins.Count <= 1);337 320 if(oldPlugins.Count == 1) { 338 321 if(oldPlugins[0].PluginVersion < availablePlugin.Version) { … … 352 335 }); 353 336 354 // either none or exactly one plugin to override can be found355 Trace.Assert(currentPlugins.Count <= 1);356 337 if(currentPlugins.Count == 1) { 357 338 if(currentPlugins[0].PluginVersion < availablePlugin.Version) { … … 374 355 MarkRemove(action.Plugin); 375 356 } else 376 Trace.Assert(false); // is not allowed to happen357 throw new InvalidOperationException(); 377 358 } 378 359 … … 387 368 388 369 private void MarkInstall(PluginTag actionTag) { 389 390 Trace.Assert(actionTag.State == PluginState.Available);391 392 370 if(!CheckInstallConflicts(actionTag)) { 393 371 CreateNewInstallAction(actionTag); … … 398 376 399 377 private void UnmarkInstall(PluginTag actionTag) { 400 Trace.Assert(actionTag.State == PluginState.Available);401 402 Trace.Assert(GetOverlappingActions(actionTag, ManagerAction.Any).TrueForAll(delegate(PluginAction fixedPoint) {403 return fixedPoint.Action == ManagerAction.Install;404 }));405 406 378 if(!CheckNoActionConflict(actionTag)) { 407 379 List<PluginAction> rootActions = GetActionsInvolving(actionTag); 408 // if there is no conflict then there can only be one action connected to the pluginTag409 Trace.Assert(rootActions.Count == 1);410 380 PluginAction rootAction = rootActions[0]; 411 381 actions.Remove(rootAction.Plugin); … … 418 388 private void HandleNoActionConflict(PluginTag actionTag) { 419 389 List<PluginAction> conflictingActions = GetOverlappingActions(actionTag, ManagerAction.Any); 420 421 Trace.Assert(conflictingActions.Count > 1);422 390 PluginAction theAction = GetSmallestActionInvolving(actionTag, conflictingActions); 423 391 conflictingActions.Remove(theAction); 424 425 426 392 string action = theAction.GetInverseActionString(); 427 428 393 DialogResult userResult = ShowGenericConflictDialog(action, theAction, conflictingActions); 429 430 394 if(userResult == DialogResult.OK) { 431 395 conflictingActions.ForEach(delegate(PluginAction conflictingAction) { … … 445 409 446 410 private void MarkRemove(PluginTag actionTag) { 447 448 Trace.Assert((actionTag.State & (PluginState.Installed | PluginState.Upgradeable)) != 0);449 450 411 if(!CheckRemoveConflicts(actionTag)) { 451 412 CreateNewRemoveAction(actionTag); … … 456 417 457 418 private void UnmarkRemove(PluginTag pluginTag) { 458 459 Trace.Assert(pluginTag.State == PluginState.Installed);460 461 Trace.Assert(GetOverlappingActions(pluginTag, ManagerAction.Any).TrueForAll(delegate(PluginAction action) {462 return action.Action == ManagerAction.Remove;463 }));464 465 419 if(!CheckNoActionConflict(pluginTag)) { 466 Trace.Assert(GetOverlappingActions(pluginTag, ManagerAction.Remove).Count == 1);467 420 List<PluginAction> rootActions = GetActionsInvolving(pluginTag); 468 421 // if there is no conflict then there can only be one action connected to the pluginTag 469 Trace.Assert(rootActions.Count == 1);470 422 PluginAction rootAction = rootActions[0]; 471 472 423 // kill the root action 473 424 actions.Remove(rootAction.Plugin); … … 547 498 548 499 private DialogResult ShowGenericConflictDialog(string action, PluginAction theAction, List<PluginAction> conflictingActions) { 549 550 Trace.Assert(conflictingActions.Count > 0);551 552 500 string message = "The actions:\n\n"; 553 501 conflictingActions.ForEach(delegate(PluginAction conflictingAction) { … … 577 525 578 526 private PluginAction GetSmallestActionInvolving(PluginTag actionTag, List<PluginAction> actions) { 579 Trace.Assert(actions.Count > 0);580 527 PluginAction smallestAction; 581 528 // if there is an action defined for which actionTag is the root then us it as root tag … … 814 761 string[] extractedFiles = Directory.GetFiles(tempDir, "*", SearchOption.AllDirectories); 815 762 foreach(string extractedFile in extractedFiles) { 816 Trace.Assert(extractedFile.StartsWith(tempDir));817 763 File.Copy(extractedFile, pluginDir + extractedFile.Remove(0, tempDir.Length)); 818 764 } … … 822 768 string[] extractedFiles = Directory.GetFiles(tempDir, "*", SearchOption.AllDirectories); 823 769 foreach(string extractedFile in extractedFiles) { 824 Trace.Assert(extractedFile.StartsWith(tempDir));825 770 string filename = pluginDir + extractedFile.Remove(0, tempDir.Length); 826 771 if(File.Exists(filename)) { … … 832 777 string[] backupFiles = Directory.GetFiles(backupDir, "*", SearchOption.AllDirectories); 833 778 foreach(string backupFile in backupFiles) { 834 Trace.Assert(backupFile.StartsWith(backupDir));835 779 File.Copy(backupFile, pluginDir + backupFile.Remove(0, backupDir.Length)); 836 780 } … … 853 797 if(tag.State == PluginState.Upgradeable || (involvingActions.Count > 0 && involvingActions[0].Action == ManagerAction.Remove)) { 854 798 tag.Plugin.Files.ForEach(delegate(string filename) { 855 Trace.Assert(filename.StartsWith(pluginDir));856 799 DialogResult result = MessageBox.Show("Deleting: " + filename, "Warning: deleting file", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); 857 800 if(result == DialogResult.OK) { … … 866 809 string[] backupFiles = Directory.GetFiles(backupDir, "*", SearchOption.AllDirectories); 867 810 foreach(string backupFile in backupFiles) { 868 Trace.Assert(backupFile.StartsWith(backupDir));869 811 string oldFileName = pluginDir + backupFile.Remove(0, backupDir.Length); 870 812 if(!File.Exists(oldFileName)) { … … 888 830 if(tag.State == PluginState.Upgradeable || (actionsInvolving.Count > 0 && actionsInvolving[0].Action == ManagerAction.Remove)) { 889 831 tag.Plugin.Files.ForEach(delegate(string filename) { 890 Trace.Assert(filename.StartsWith(pluginDir));891 832 File.Copy(filename, backupDir + filename.Remove(0, pluginDir.Length)); 892 833 }); … … 998 939 999 940 private void removeButton_Clicked(object sender, EventArgs e) { 1000 AssertAction();1001 941 // get the tag of the selected treeNode 1002 942 PluginTag actionTag = (PluginTag)pluginTreeView.SelectedNode.Tag; 1003 943 List<PluginAction> rootActions = GetActionsInvolving(actionTag); 1004 944 if(rootActions.Count>0) { 1005 Trace.Assert(rootActions.TrueForAll(delegate(PluginAction rootAction) {1006 return rootAction.Action == ManagerAction.Remove;1007 }));1008 945 UnmarkRemove(actionTag); 1009 946 } else { … … 1018 955 1019 956 private void installButton_Clicked(object sender, EventArgs e) { 1020 AssertAction();1021 957 // get the tag of the selected treeNode 1022 958 PluginTag actionTag = (PluginTag)pluginTreeView.SelectedNode.Tag; … … 1024 960 1025 961 if(rootActions.Count > 0) { 1026 Trace.Assert(rootActions.TrueForAll(delegate(PluginAction rootAction) {1027 return rootAction.Action == ManagerAction.Install;1028 }));1029 962 UnmarkInstall(actionTag); 1030 963 } else { … … 1036 969 // update the plugin detail information of the selected plugin 1037 970 DisplayPluginInfo(actionTag.GetPluginDetails()); 1038 }1039 1040 private void AssertAction() {1041 Trace.Assert(pluginTreeView.SelectedNode != null);1042 Trace.Assert(pluginTreeView.SelectedNode.Tag is PluginTag);1043 971 } 1044 972 … … 1101 1029 // check if none of the files exist 1102 1030 foreach(string filename in Directory.GetFiles(cacheDir)) { 1103 Trace.Assert(filename.StartsWith(cacheDir));1104 1031 if(File.Exists(pluginDir + filename.Remove(0, cacheDir.Length))) { 1105 1032 ShowErrorDialog("Sorry can't install the plugin "+packageName+"\nThe file: "+filename.Remove(0, cacheDir.Length)+" already exist in "+pluginDir+"\nIt seems the plugin is already installed."); -
trunk/sources/HeuristicLab.PluginInfrastructure.GUI/PluginAction.cs
r2 r8 64 64 default: 65 65 // this method is not defined for actions other than "Install" and "Remove" 66 Trace.Assert(false);66 throw new InvalidOperationException(); 67 67 return ""; 68 68 } -
trunk/sources/HeuristicLab.PluginInfrastructure.GUI/PluginNameTransform.cs
r2 r8 44 44 45 45 public string TransformFile(string name) { 46 //Trace.Assert(name.StartsWith(pluginDir));47 46 if(name.StartsWith(pluginDir)) { 48 47 return name.Remove(0, pluginDir.Length); -
trunk/sources/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs
r2 r8 39 39 40 40 // exactly one attribute of the type ClassInfoAttribute must be given 41 Trace.Assert(pluginAttributes.Length == 1); 41 if(pluginAttributes.Length != 1) { 42 throw new InvalidPluginException(); 43 } 42 44 43 45 // after the assertion we are sure that the array access will not fail -
trunk/sources/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs
r2 r8 44 44 45 45 // exactly one attribute of the type ClassInfoAttribute must be given 46 Trace.Assert(pluginAttributes.Length == 1); 46 if(pluginAttributes.Length != 1) { 47 throw new InvalidPluginException(); 48 } 47 49 48 50 // after the assertion we are sure that the array access will not fail -
trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
r2 r8 55 55 <Compile Include="Interfaces\IControl.cs" /> 56 56 <Compile Include="Interfaces\IControlManager.cs" /> 57 <Compile Include="InvalidPluginException.cs" /> 57 58 <Compile Include="PluginManager.cs" /> 58 59 <Compile Include="PluginManagerActionEventArgs.cs" /> -
trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs
r2 r8 217 217 this.pluginAssemblies[pluginName] = pluginAssemblies; 218 218 } else { 219 Trace.Assert(false);219 throw new InvalidPluginException(); 220 220 } 221 221 } -
trunk/sources/HeuristicLab/MainForm.cs
r2 r8 77 77 78 78 private void applicationsListView_ItemActivate(object sender, EventArgs e) { 79 if(applicationsListView.SelectedItems.Count > 0) { 80 Trace.Assert(applicationsListView.SelectedItems.Count == 1); 79 if(applicationsListView.SelectedItems.Count > 0) { 81 80 ListViewItem selected = applicationsListView.SelectedItems[0]; 82 81 if(selected == pluginManagerListViewItem) {
Note: See TracChangeset
for help on using the changeset viewer.