Changeset 18030
- Timestamp:
- 07/26/21 14:28:29 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateGenerator.cs
r17843 r18030 32 32 JArray resultItems = new JArray(); 33 33 IList<IJsonItem> jsonItems = new List<IJsonItem>(); 34 34 35 string templateName = Path.GetFileName(templatePath); 35 36 string templateDirectory = Path.GetDirectoryName(templatePath); … … 45 46 #region Serialize HL File 46 47 ProtoBufSerializer serializer = new ProtoBufSerializer(); 48 // get absolute path for serialization 47 49 string hlFilePath = Path.Combine(templateDirectory, $"{templateName}.hl"); 48 50 serializer.Serialize(optimizer, hlFilePath); 51 // overwrite string for relative path 52 hlFilePath = Path.Combine($".{Path.DirectorySeparatorChar}", $"{templateName}.hl"); 49 53 #endregion 50 54 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r18026 r18030 3 3 using System.IO; 4 4 using System.Linq; 5 using System.Text.RegularExpressions; 5 6 using HEAL.Attic; 6 7 using HeuristicLab.Optimization; … … 51 52 52 53 // 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)}"); 54 57 55 58 #region Deserialize HL File … … 108 111 foreach (JObject obj in Config) { 109 112 // 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(); 111 117 // override default value 112 118 if (Objects.TryGetValue(path, out IJsonItem param)) {
Note: See TracChangeset
for help on using the changeset viewer.