Changeset 2504 for branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses
- Timestamp:
- 11/18/09 18:33:30 (15 years ago)
- Location:
- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs
r2488 r2504 27 27 namespace HeuristicLab.PluginInfrastructure { 28 28 /// <summary> 29 /// Defaultimplementation for the IApplication interface.29 /// Abstract base implementation for the IApplication interface. 30 30 /// </summary> 31 31 public abstract class ApplicationBase : IApplication { … … 33 33 /// Initializes a new instance of <see cref="ApplicationBase"/>. 34 34 /// </summary> 35 p ublicApplicationBase() { }35 protected ApplicationBase() { } 36 36 37 37 private ApplicationAttribute ApplicationAttribute { … … 40 40 41 41 // exactly one attribute of the type ClassInfoAttribute must be given 42 if (appAttributes.Length != 1) { 42 if (appAttributes.Length == 0) { 43 throw new InvalidPluginException("ApplicationAttribute on type " + this.GetType() + " is missing."); 44 } else if (appAttributes.Length > 1) { 43 45 throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType()); 44 46 } … … 58 60 59 61 /// <summary> 60 /// Gets the version of the application.61 /// </summary>62 public Version Version {63 get {64 return this.GetType().Assembly.GetName().Version;65 }66 }67 68 /// <summary>69 62 /// Gets the description of the application. 70 63 /// </summary> 71 64 public string Description { 72 65 get { 73 var appDescAttribute = ApplicationAttribute; 74 // if the description is not explicitly set in the attribute then the name of the application is used as default 75 if (string.IsNullOrEmpty(appDescAttribute.Description)) { 76 return appDescAttribute.Name; 77 } else { 78 return appDescAttribute.Description; 79 } 80 } 81 } 82 83 /// <summary> 84 /// Gets the boolean flag whether the application should by restarted after exceptions. 85 /// </summary> 86 public bool RestartOnErrors { 87 get { 88 return ApplicationAttribute.RestartOnErrors; 66 return ApplicationAttribute.Description; 89 67 } 90 68 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs
r2503 r2504 29 29 namespace HeuristicLab.PluginInfrastructure { 30 30 /// <summary> 31 /// Defaultimplementation of the IPlugin interface.31 /// Abstract base implementation of the IPlugin interface. 32 32 /// </summary> 33 33 public abstract class PluginBase : IPlugin { … … 35 35 /// Initializes a new instance of <see cref="PluginBase"/>. 36 36 /// </summary> 37 p ublicPluginBase() { }37 protected PluginBase() { } 38 38 39 39 private PluginAttribute PluginAttribute { … … 41 41 object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false); 42 42 // exactly one attribute of the type PluginDescriptionAttribute must be given 43 if (pluginAttributes.Length != 1) { 43 if (pluginAttributes.Length == 0) { 44 throw new InvalidPluginException("PluginAttribute on type " + this.GetType() + " is missing."); 45 } else if (pluginAttributes.Length > 1) { 44 46 throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType()); 45 47 } … … 56 58 } 57 59 58 59 /// <inheritdoc/>60 public IEnumerable<string> FileNames {61 get {62 // get all attributes of type PluginFileAttribute, multiple usage is possible63 return from x in this.GetType().GetCustomAttributes(typeof(PluginFileAttribute), false)64 let pluginFileAttr = (PluginFileAttribute)x65 select pluginFileAttr.Filename;66 }67 }68 69 60 /// <inhertitdoc> 70 61 public virtual void OnLoad() { }
Note: See TracChangeset
for help on using the changeset viewer.