Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2924_DotNetCoreMigration/HeuristicLab.PluginInfrastructure/3.3/ApplicationBase.cs @ 16993

Last change on this file since 16993 was 16993, checked in by dpiringe, 5 years ago

#2924:

  • added IEnumerable<T> GetInstances<T>(params object[] args) where T: class and IEnumerable<object> GetInstances(Type type, params object[] args) method to IApplicationManager and implemented them in LightweightApplicationManager -> to instantiate types with specific constructor arguments
  • added RunnerState State { get; } property in IRunnerHost, was already in RunnerHost
  • added user authentication for NativeRunnerHost
  • added optional check for a running docker daemon and available image for type DockerRunnerHost + Exception DockerException
  • added caching of the saved IApplication in ApplicationRunner to prevent a new instance every get call
  • removed System.ServiceModel.Primitives NuGet package
  • lots of formatting
File size: 2.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22
23using System;
24
25namespace HeuristicLab.PluginInfrastructure {
26  /// <summary>
27  /// Abstract base implementation for the IApplication interface.
28  /// </summary>
29  [Serializable]
30  public abstract class ApplicationBase : IApplication {
31    /// <summary>
32    /// Initializes a new instance of <see cref="ApplicationBase"/>.
33    /// </summary>
34    protected ApplicationBase() { }
35
36    private ApplicationAttribute ApplicationAttribute {
37      get {
38        object[] appAttributes = GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
39
40        // exactly one attribute of the type ClassInfoAttribute must be given
41        if (appAttributes.Length == 0) {
42          throw new InvalidPluginException("ApplicationAttribute on type " + GetType() + " is missing.");
43        } else if (appAttributes.Length > 1) {
44          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + GetType());
45        }
46
47        return (ApplicationAttribute)appAttributes[0];
48      }
49    }
50
51    #region IApplication Members
52    /// <summary>
53    /// Gets the name of the application.
54    /// </summary>
55    public string Name => ApplicationAttribute.Name;
56
57    /// <summary>
58    /// Gets the description of the application.
59    /// </summary>
60    public string Description => ApplicationAttribute.Description;
61
62    /// <summary>
63    /// Runs the application.
64    /// </summary>
65    public abstract void Run(ICommandLineArgument[] args);
66
67    public virtual void OnCancel() { }
68    public virtual void OnPause() { }
69    public virtual void OnResume() { }
70    #endregion
71  }
72}
Note: See TracBrowser for help on using the repository browser.