Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/21 14:28:29 (3 years ago)
Author:
dpiringe
Message:

#3026

  • added check for missing path property
  • added functionality for relative .hl file paths
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r18026 r18030  
    33using System.IO;
    44using System.Linq;
     5using System.Text.RegularExpressions;
    56using HEAL.Attic;
    67using HeuristicLab.Optimization;
     
    5152
    5253      // extract metadata information
    53       string hLFileLocation = Path.GetFullPath(Template[Constants.Metadata][Constants.HLFileLocation].ToString());
     54      string relativePath = Template[Constants.Metadata][Constants.HLFileLocation].ToString(); // get relative path
     55      // convert to absolute path
     56      string hLFileLocation = Regex.Replace(relativePath, @"^(\.)", $"{Path.GetDirectoryName(templateFile)}");
    5457
    5558      #region Deserialize HL File
     
    108111      foreach (JObject obj in Config) {
    109112        // build item from config object
    110         string path = obj.Property("Path").Value.ToString(); // TODO: catch exception if path is not available
     113        var prop = obj.Property("Path");
     114        if (prop == null)
     115          throw new ArgumentException("Path property is missing.");
     116        string path = prop.Value.ToString();
    111117        // override default value
    112118        if (Objects.TryGetValue(path, out IJsonItem param)) {
Note: See TracChangeset for help on using the changeset viewer.