Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/18/09 18:33:30 (15 years ago)
Author:
gkronber
Message:

Worked on core of plugin infrastructure.

  • Collected all classes into a single assembly (HL.PluginInfrastructure)
  • Moved SplashScreen and MainForm from HeuristicLab.exe project into the plugin infrastructure.
  • Introduced namespaces
  • Added strict access modifiers (internal)
  • Fixed most FxCop warnings in plugin infrastructure core.
  • Fixed issues with plugin load/unload events
  • Deleted empty interface IControl

#799

Location:
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs

    r2488 r2504  
    2727namespace HeuristicLab.PluginInfrastructure {
    2828  /// <summary>
    29   /// Default implementation for the IApplication interface.
     29  /// Abstract base implementation for the IApplication interface.
    3030  /// </summary>
    3131  public abstract class ApplicationBase : IApplication {
     
    3333    /// Initializes a new instance of <see cref="ApplicationBase"/>.
    3434    /// </summary>
    35     public ApplicationBase() { }
     35    protected ApplicationBase() { }
    3636
    3737    private ApplicationAttribute ApplicationAttribute {
     
    4040
    4141        // 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) {
    4345          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType());
    4446        }
     
    5860
    5961    /// <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>
    6962    /// Gets the description of the application.
    7063    /// </summary>
    7164    public string Description {
    7265      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;
    8967      }
    9068    }
  • branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs

    r2503 r2504  
    2929namespace HeuristicLab.PluginInfrastructure {
    3030  /// <summary>
    31   /// Default implementation of the IPlugin interface.
     31  /// Abstract base implementation of the IPlugin interface.
    3232  /// </summary>
    3333  public abstract class PluginBase : IPlugin {
     
    3535    /// Initializes a new instance of <see cref="PluginBase"/>.
    3636    /// </summary>
    37     public PluginBase() { }
     37    protected PluginBase() { }
    3838
    3939    private PluginAttribute PluginAttribute {
     
    4141        object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
    4242        // 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) {
    4446          throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType());
    4547        }
     
    5658    }
    5759
    58 
    59     /// <inheritdoc/>
    60     public IEnumerable<string> FileNames {
    61       get {
    62         // get all attributes of type PluginFileAttribute, multiple usage is possible
    63         return from x in this.GetType().GetCustomAttributes(typeof(PluginFileAttribute), false)
    64                let pluginFileAttr = (PluginFileAttribute)x
    65                select pluginFileAttr.Filename;
    66       }
    67     }
    68 
    6960    /// <inhertitdoc>
    7061    public virtual void OnLoad() { }
Note: See TracChangeset for help on using the changeset viewer.