Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2924_DotNetCoreMigration/HeuristicLab.DynamicAssemblyTestApp/AppTest.cs @ 16985

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

#2924:

  • added CLI Framework HeuristicLab.CommandLineInterface
  • added definition language test project HeuristicLab.DefinitionLanguage
  • added test project HeuristicLab.DynamicAssemblyTestApp, for PluginInfrastructure testing
  • changed project HeuristicLab to .NET Core and used it to create a CLI-Tool with the new CLI Framework
  • added Docker support to HeuristicLab
  • added IRunnerHost.cs ... forgot last commit
  • changed DockerRunnerHost and NativeRunnerHost to HeuristicLab-3.3.exe, was a little test project before
  • added new solution file HeuristicLab 3.3 No Views.sln, where all view projects are unloaded at start
File size: 1.4 KB
Line 
1using System;
2using System.IO;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Optimization;
6using HeuristicLab.PluginInfrastructure;
7
8namespace HeuristicLab.DynamicAssemblyTestApp {
9  [Serializable]
10  public class AppTest : ApplicationBase {
11
12    public UniPath InputFilePath { get; set; } = null;
13    public UniPath OutputPath { get; set; } = null;
14    public override void Run(ICommandLineArgument[] args) {
15      ContentManager.Initialize(new PersistenceContentManager());
16      IStorableContent content = ContentManager.Load(InputFilePath.ToString());
17      IExecutable exec = content as IExecutable;
18      if (exec != null) {
19        exec.Start();
20        IOptimizer optimizer = exec as IOptimizer;
21        if (optimizer != null) {
22          Console.WriteLine("\nRESULT(S):");
23          int i = 1;
24          foreach (var run in optimizer.Runs) {
25            Console.WriteLine($"{"-------------------------------- RUN",35} {$"{i++:D3}" + " --------------------------------",-35}");
26            foreach (var res in run.Results) {
27              Console.WriteLine($"{res.Key,35} : {res.Value,-35}");
28            }
29          }
30        }
31       
32        ContentManager.Save((IStorableContent)exec, OutputPath.ToString() + Path.DirectorySeparatorChar + "result.hl", true);
33      } else throw new NotSupportedException("The given file does not contain any algorithm to start.");
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.