Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2924:

  • some changes in CLIApplication.cs to reduce unnecessary allocation of string objects
  • renamed AppTest to ConsoleOptimizer and fixed race condition
  • replaced enum RunnerJob with class RunnerMessage for more control of saved data
  • changed usage of BinaryFormatter with HEAL.Attic, following types are now Storable:
    • ConsoleOptimizer
    • InspectApplication
    • ApplicationBase
    • ApplicationRunner
    • AssemblyInfo
    • Runner
    • UniPath
    • RunnerMessage
  • switched QuietMode from ApplicationRunner to IRunner
  • DockerRunnerHost can now automatically build docker images for linux and windows containers (also identifies which container type is active) -> removes the condition to have the image preinstalled
    • to achieve this, there are two new folders DockerLinuxBuild and DockerWindowsBuild included in build output, which include Dockerfiles to build images for linux and windows container
  • added NuGet package System.CodeDom to project HeuristicLab.Scripting-3.3
  • added method Send(RunnerMessage) to IRunnerHost and transferred methods Pause and Resume to IRunner
  • added internal reference of RunnerHost in Runner
  • added abstract method SendMessage(RunnerMessage) in RunnerHost which gets called from method Send(RunnerMessage)
  • because of a Google.Protobuf "bug", RunnerMessages cannot get serialized/deserialized directly on stream -> workaround with a byte array, which gets written and read
    • additionally, the length of the array gets sent first (length as integer -> 4 bytes)
    • static method in RunnerMessage to read a message from a stream
    • the method SendMessage(RunnerMessage) in RunnerHost implements this functionality
File size: 2.5 KB
RevLine 
[2]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[2]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
[17013]23using HEAL.Attic;
[16984]24
[2]25namespace HeuristicLab.PluginInfrastructure {
[1189]26  /// <summary>
[2504]27  /// Abstract base implementation for the IApplication interface.
[1189]28  /// </summary>
[17013]29  [StorableType("FB13839C-2EEC-4C6F-BEF3-A1CAE4467362")]
[2488]30  public abstract class ApplicationBase : IApplication {
[1189]31    /// <summary>
32    /// Initializes a new instance of <see cref="ApplicationBase"/>.
33    /// </summary>
[2504]34    protected ApplicationBase() { }
[2]35
[2488]36    private ApplicationAttribute ApplicationAttribute {
[2475]37      get {
[16993]38        object[] appAttributes = GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
[2]39
[2475]40        // exactly one attribute of the type ClassInfoAttribute must be given
[2504]41        if (appAttributes.Length == 0) {
[16993]42          throw new InvalidPluginException("ApplicationAttribute on type " + GetType() + " is missing.");
[2504]43        } else if (appAttributes.Length > 1) {
[16993]44          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + GetType());
[242]45        }
[2]46
[2488]47        return (ApplicationAttribute)appAttributes[0];
[2]48      }
49    }
50
51    #region IApplication Members
[1189]52    /// <summary>
53    /// Gets the name of the application.
54    /// </summary>
[16993]55    public string Name => ApplicationAttribute.Name;
[2]56
[1189]57    /// <summary>
58    /// Gets the description of the application.
59    /// </summary>
[16993]60    public string Description => ApplicationAttribute.Description;
[2]61
[1189]62    /// <summary>
63    /// Runs the application.
64    /// </summary>
[8818]65    public abstract void Run(ICommandLineArgument[] args);
[242]66
[16993]67    public virtual void OnCancel() { }
68    public virtual void OnPause() { }
69    public virtual void OnResume() { }
[2]70    #endregion
71  }
72}
Note: See TracBrowser for help on using the repository browser.