Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/13/08 20:24:46 (16 years ago)
Author:
gkronber
Message:

added support for "service" applications that are restarted automatically when they crash with an exception. (related to #149)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs

    r8 r242  
    3030    private Version version;
    3131    private string description;
    32    
     32    private bool autoRestart;
     33
    3334    public ApplicationBase() {
    3435      ReadAttributes();
     
    4546      // after the assertion we are sure that the array access will not fail
    4647      ClassInfoAttribute pluginAttribute = (ClassInfoAttribute)pluginAttributes[0];
     48      if(pluginAttribute != null) {
     49        // if the plugin name is not explicitly set in the attribute then the default plugin name is the FullName of the type
     50        if(pluginAttribute.Name != null) {
     51          this.name = pluginAttribute.Name;
     52        } else {
     53          this.name = this.GetType().FullName;
     54        }
    4755
    48       // if the plugin name is not explicitly set in the attribute then the default plugin name is the FullName of the type
    49       if(pluginAttribute != null && pluginAttribute.Name != null) {
    50         this.name = pluginAttribute.Name;
    51       } else {
    52         this.name = this.GetType().FullName;
    53       }
     56        // if the version is not explicitly set in the attribute then the version of the assembly is used as default
     57        if(pluginAttribute.Version != null) {
     58          this.version = new Version(pluginAttribute.Version);
     59        } else {
     60          this.version = this.GetType().Assembly.GetName().Version;
     61        }
    5462
    55       // if the version is not explicitly set in the attribute then the version of the assembly is used as default
    56       if(pluginAttribute != null && pluginAttribute.Version != null) {
    57         this.version = new Version(pluginAttribute.Version);
    58       } else {
    59         this.version = this.GetType().Assembly.GetName().Version;
    60       }
     63        // if the description is not explicitly set in the attribute then the name of name of the application is used as default
     64        if(pluginAttribute.Description != null) {
     65          this.description = pluginAttribute.Description;
     66        } else {
     67          this.description = name;
     68        }
    6169
    62       // if the description is not explicitly set in the attribute then the name of name of the application is used as default
    63       if(pluginAttribute != null && pluginAttribute.Description != null) {
    64         this.description = pluginAttribute.Description;
    65       } else {
    66         this.description = name;
     70        this.autoRestart = pluginAttribute.AutoRestart;
    6771      }
    6872    }
     
    8387    }
    8488
    85     public abstract void Run() ;
     89    public bool AutoRestart {
     90      get { return autoRestart; }
     91    }
     92
     93    public abstract void Run();
    8694
    8795    #endregion
Note: See TracChangeset for help on using the changeset viewer.