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

Last change on this file since 17013 was 17013, checked in by dpiringe, 2 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: 875 bytes
Line 
1using System.IO;
2using System.Linq;
3using HeuristicLab.CommandLineInterface;
4using HeuristicLab.PluginInfrastructure;
5
6namespace HeuristicLab {
7  [Command(Description = "To inspect a .hl file.")]
8  class InspectCommand : ICommand {
9
10    [Value(0)]
11    public string Input { get; set; }
12
13    public void Execute() {
14      if (Input == null || !File.Exists(Input))
15        throw new FileNotFoundException("Path to .hl file empty or wrong!");
16
17      if (Settings.Host != null) {
18        Settings.Host.QuietMode = false;
19        Settings.Host.Run(new ApplicationRunner() {
20          AssembliesToLoad = Settings.assemblyInfos,
21          StartApplication =
22            ApplicationManager.Manager.GetInstances<IApplication>(new UniPath(Input))
23            .Where(x => x.Name.Equals("CLIInspect"))
24            .First()
25
26        });
27      }
28    }
29  }
30}
Note: See TracBrowser for help on using the repository browser.