Changeset 17394
- Timestamp:
- 01/07/20 16:25:39 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 2 added
- 3 deleted
- 23 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r17349 r17394 11 11 internal static class Runner { 12 12 internal static void Run(string template, string config, string outputFile = @"C:\Workspace\test.txt") { 13 IAlgorithm alg = J CInstantiator.Instantiate(template, config);13 IAlgorithm alg = JsonTemplateInstantiator.Instantiate(template, config); 14 14 15 15 Task task = alg.StartAsync(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/FileManager.cs
r17354 r17394 63 63 if (openFileDialog.ShowDialog() == DialogResult.OK) { 64 64 try { 65 var content = J CInstantiator.Instantiate(openFileDialog.FileName);65 var content = JsonTemplateInstantiator.Instantiate(openFileDialog.FileName); 66 66 IView view = MainFormManager.MainForm.ShowContent(content); 67 67 if (view == null) -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
r17379 r17394 11 11 public abstract class BaseConverter : IJsonItemConverter 12 12 { 13 public void Inject(IItem item, JsonItem data) { 14 InjectData(item, data); 13 public abstract int Priority { get; } 14 public abstract Type ConvertableType { get; } 15 16 public void Inject(IItem item, JsonItem data, IJsonItemConverter root) { 17 18 InjectData(item, data, root); 15 19 } 16 20 17 public JsonItem Extract(IItem value ) {18 JsonItem data = ExtractData(value);19 data.Name = string.IsNullOrEmpty(data.Name) ? value.ItemName : data.Name;21 public JsonItem Extract(IItem value, IJsonItemConverter root) { 22 JsonItem data = new JsonItem() { Name = value.ItemName }; 23 Populate(value, data, root); 20 24 return data; 21 25 } 22 26 23 public abstract void InjectData(IItem item, JsonItem data );24 public abstract JsonItem ExtractData(IItem value);27 public abstract void InjectData(IItem item, JsonItem data, IJsonItemConverter root); 28 public abstract void Populate(IItem value, JsonItem item, IJsonItemConverter root); 25 29 26 30 #region Helper 27 31 protected ValueType CastValue<ValueType>(object obj) { 28 32 if (obj is JToken) 29 return obj.Cast<JToken>().ToObject<ValueType>();33 return ((JToken)obj).ToObject<ValueType>(); 30 34 else if (obj is IConvertible) 31 return Convert.ChangeType(obj, typeof(ValueType)).Cast<ValueType>();35 return (ValueType)Convert.ChangeType(obj, typeof(ValueType)); 32 36 else return (ValueType)obj; 33 37 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17379 r17394 9 9 namespace HeuristicLab.JsonInterface { 10 10 public class ConstrainedValueParameterConverter : ParameterBaseConverter { 11 public override void InjectData(IParameter parameter, JsonItem data) { 11 public override int Priority => 3; 12 public override Type ConvertableType => typeof(IConstrainedValueParameter<>); 13 14 public override void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root) { 12 15 foreach(var x in GetValidValues(parameter)) 13 16 if(x.ToString() == CastValue<string>(data.Value)) … … 17 20 foreach(var param in data.Children) { 18 21 if(param.Name == parameter.ActualValue.ItemName) 19 JsonItemConverter.Inject(parameter.ActualValue, param);22 root.Inject(parameter.ActualValue, param, root); 20 23 } 21 24 } 22 25 } 23 26 24 public override JsonItem ExtractData(IParameter value) => 25 new JsonItem() { 26 Name = value.Name, 27 Value = value.ActualValue?.ToString(), 28 Range = GetValidValues(value).Select(x => x.ToString()), 29 Children = GetParameterizedChilds(value) 30 }; 27 public override void Populate(IParameter value, JsonItem item, IJsonItemConverter root) { 28 item.AddChilds(GetParameterizedChilds(value)); 29 item.Name = value.Name; 30 item.Value = value.ActualValue?.ToString(); 31 item.Range = GetValidValues(value).Select(x => x.ToString()); 32 } 31 33 32 34 #region Helper 33 35 private IItem[] GetValidValues(IParameter value) { 34 36 List<IItem> list = new List<IItem>(); 35 var values = value.Cast<dynamic>().ValidValues;37 var values = ((dynamic)value).ValidValues; 36 38 foreach (var x in values) list.Add((IItem)x); 37 39 return list.ToArray(); … … 40 42 private IList<JsonItem> GetParameterizedChilds(IParameter value) { 41 43 List<JsonItem> list = new List<JsonItem>(); 42 var values = value.Cast<dynamic>().ValidValues;44 var values = ((dynamic)value).ValidValues; 43 45 foreach(var x in values) { 44 46 if (x is IParameterizedItem) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs
r17342 r17394 9 9 namespace HeuristicLab.JsonInterface { 10 10 public class EnumTypeConverter : BaseConverter { 11 public override void InjectData(IItem item, JsonItem data) => 12 item.Cast<dynamic>().Value = Enum.Parse( 11 public override int Priority => 1; 12 public override Type ConvertableType => typeof(EnumValue<>); 13 14 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 15 ((dynamic)item).Value = Enum.Parse( 13 16 item.GetType().GenericTypeArguments.First(), 14 17 CastValue<string>(data.Value)); 15 18 16 public override JsonItem ExtractData(IItem value) { 17 JsonItem data = new JsonItem(); 19 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 18 20 object val = ((dynamic)value).Value; 19 21 Type enumType = val.GetType(); 20 data.Value = Enum.GetName(enumType, val); 21 data.Range = Enum.GetNames(enumType); 22 return data; 22 item.Value = Enum.GetName(enumType, val); 23 item.Range = Enum.GetNames(enumType); 23 24 } 24 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/LookupParameterConverter.cs
r17342 r17394 8 8 namespace HeuristicLab.JsonInterface { 9 9 public class LookupParameterConverter : ParameterBaseConverter { 10 public override JsonItem ExtractData(IParameter value) => 11 new JsonItem() { 12 Name = value.Name, 13 ActualName = value.Cast<ILookupParameter>().ActualName 14 }; 10 public override int Priority => 3; 11 public override Type ConvertableType => typeof(ILookupParameter); 15 12 16 public override void InjectData(IParameter parameter, JsonItem data) => 17 parameter.Cast<ILookupParameter>().ActualName = data.ActualName.Cast<string>(); 13 public override void Populate(IParameter value, JsonItem item, IJsonItemConverter root) { 14 item.Name = value.Name; 15 item.ActualName = ((ILookupParameter)value).ActualName; 16 } 17 18 public override void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root) => 19 ((ILookupParameter)parameter).ActualName = data.ActualName as string; 18 20 } 19 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r17379 r17394 9 9 namespace HeuristicLab.JsonInterface { 10 10 public class MultiCheckedOperatorConverter : ParameterizedItemConverter { 11 public override JsonItem ExtractData(IItem value) {12 JsonItem data = base.ExtractData(value);11 public override int Priority => 3; 12 public override Type ConvertableType => typeof(ICheckedMultiOperator<>); 13 13 14 if(data.Children == null) 15 data.Children = new List<JsonItem>(); 16 dynamic val = value.Cast<dynamic>(); 14 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 15 base.Populate(value, item, root); 16 17 dynamic val = value as dynamic; 17 18 foreach (var op in val.Operators) { 18 data.Children.Add(new JsonItem() {19 item.AddChilds(new JsonItem() { 19 20 Name = op.Name, 20 21 Value = val.Operators.ItemChecked(op), … … 22 23 }); 23 24 } 24 return data;25 25 } 26 26 27 public override void InjectData(IItem item, JsonItem data ) {28 base.InjectData(item, data );27 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) { 28 base.InjectData(item, data, root); 29 29 30 dynamic val = item .Cast<dynamic>();30 dynamic val = item as dynamic; 31 31 foreach (var op in val.Operators) 32 32 val.Operators.SetItemCheckedState(op, GetOperatorState(op.Name, data)); … … 35 35 private bool GetOperatorState(string name, JsonItem data) { 36 36 foreach(var op in data.Children) { 37 if (op.Name == name && op.Value is bool) return op.Value.Cast<bool>();37 if (op.Name == name && op.Value is bool) return (bool)op.Value; 38 38 } 39 39 return false; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterBaseConverter.cs
r17379 r17394 8 8 namespace HeuristicLab.JsonInterface { 9 9 public abstract class ParameterBaseConverter : BaseConverter { 10 public override JsonItem ExtractData(IItem value) =>11 ExtractData(value.Cast<IParameter>());10 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) => 11 Populate(value as IParameter, item, root); 12 12 13 public abstract JsonItem ExtractData(IParameter value);13 public abstract void Populate(IParameter value, JsonItem item, IJsonItemConverter root); 14 14 15 public override void InjectData(IItem item, JsonItem data) => InjectData(item.Cast<IParameter>(), data); 15 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 16 InjectData(item as IParameter, data, root); 16 17 17 public abstract void InjectData(IParameter parameter, JsonItem data );18 public abstract void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root); 18 19 } 19 20 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17379 r17394 8 8 namespace HeuristicLab.JsonInterface { 9 9 public class ParameterizedItemConverter : BaseConverter { 10 public override void InjectData(IItem item, JsonItem data) { 11 IParameterizedItem pItem = item.Cast<IParameterizedItem>(); 10 public override int Priority => 2; 11 public override Type ConvertableType => typeof(IParameterizedItem); 12 13 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) { 14 IParameterizedItem pItem = item as IParameterizedItem; 12 15 13 16 if(data.Children != null) { 14 17 foreach (var sp in data.Children) 15 18 if (pItem.Parameters.TryGetValue(sp.Name, out IParameter param)) 16 JsonItemConverter.Inject(param, sp);19 root.Inject(param, sp, root); 17 20 } 18 21 } 19 22 20 public override JsonItem ExtractData(IItem value) { 21 JsonItem item = new JsonItem(); 23 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 22 24 var parameterizedItem = value as IParameterizedItem; 23 25 24 26 foreach (var param in parameterizedItem.Parameters) { 25 if(!param.Hidden) { 26 JsonItem data = JsonItemConverter.Extract(param); 27 //data.Name = param.Name; 28 29 if (item.Children == null) 30 item.Children = new List<JsonItem>(); 31 item.Children.Add(data); 32 } 27 if(!param.Hidden) 28 item.AddChilds(root.Extract(param, root)); 33 29 } 34 return item;35 30 } 36 31 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17379 r17394 11 11 public class RegressionProblemDataConverter : BaseConverter { 12 12 private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; 13 public override JsonItem ExtractData(IItem value) { 14 JsonItem item = new JsonItem() { 15 Path = value.ItemName, 16 Children = new List<JsonItem>() 17 }; 18 13 public override int Priority => 20; 14 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C")); 15 16 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 19 17 dynamic val = (dynamic)value; 20 18 object dataset = (object)val.Dataset; … … 22 20 FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags); 23 21 // TODO: aufteilen in trainings und test daten abschnitte 24 item. Children.Add(new JsonItem() {22 item.AddChilds(new JsonItem() { 25 23 Name = "Dataset", 26 Value = dataInfo.GetValue(dataset), 27 Path = "Dataset" 24 Value = dataInfo.GetValue(dataset) 28 25 }); 29 26 30 27 IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables; 31 item. Children.Add(new JsonItem() {28 item.AddChilds(new JsonItem() { 32 29 Name = "TargetVariable", 33 30 Value = (object)targetVariable, 34 Range = variables.Select(x => x.Value), 35 Path = "TargetVariable" 31 Range = variables.Select(x => x.Value) 36 32 }); 37 33 38 34 39 item. Children.Add(new JsonItem() {35 item.AddChilds(new JsonItem() { 40 36 Name = "AllowedInputVariables", 41 37 Value = (object)val.AllowedInputVariables, 42 Range = variables.Select(x => x.Value), 43 Path = "AllowedInputVariables" 38 Range = variables.Select(x => x.Value) 44 39 }); 45 46 item.UpdatePath();47 48 return item;49 40 } 50 41 51 public override void InjectData(IItem item, JsonItem data ) {42 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) { 52 43 // TODO: inject data 53 44 throw new NotImplementedException(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs
r17342 r17394 9 9 namespace HeuristicLab.JsonInterface { 10 10 public class StringValueConverter : BaseConverter { 11 public override void InjectData(IItem item, JsonItem data) =>12 item.Cast<StringValue>().Value = CastValue<string>(data.Value);11 public override int Priority => 1; 12 public override Type ConvertableType => typeof(StringValue); 13 13 14 public override JsonItem ExtractData(IItem value) => 15 new JsonItem() { 16 Value = value.Cast<StringValue>().Value 17 }; 14 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 15 ((StringValue)item).Value = CastValue<string>(data.Value); 16 17 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) => 18 item.Value = ((StringValue)value).Value; 18 19 } 19 20 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r17379 r17394 8 8 namespace HeuristicLab.JsonInterface { 9 9 public class ValueLookupParameterConverter : ParameterBaseConverter { 10 public override JsonItem ExtractData(IParameter value) { 11 IValueLookupParameter param = value.Cast<IValueLookupParameter>(); 10 public override int Priority => 4; 11 public override Type ConvertableType => typeof(IValueLookupParameter); 12 13 public override void Populate(IParameter value, JsonItem item, IJsonItemConverter root) { 14 IValueLookupParameter param = value as IValueLookupParameter; 15 16 item.Name = value.Name; 17 item.ActualName = param.ActualName; 18 12 19 object actualValue = null; 13 20 IEnumerable<object> actualRange = null; 14 21 if(param.Value != null) { 15 JsonItem tmp = JsonItemConverter.Extract(param.Value); 22 JsonItem tmp = root.Extract(param.Value, root); 23 tmp.Parent = item; 16 24 actualValue = tmp.Value; 17 25 actualRange = tmp.Range; … … 19 27 actualRange = new object[] { GetMinValue(param.DataType), GetMaxValue(param.DataType) }; 20 28 } 21 22 return new JsonItem() { 23 Name = value.Name, 24 ActualName = param.ActualName, 25 Value = actualValue, 26 Range = actualRange 27 }; 29 item.Value = actualValue; 30 item.Range = actualRange; 28 31 } 29 32 30 public override void InjectData(IParameter parameter, JsonItem data ) {31 IValueLookupParameter param = parameter .Cast<IValueLookupParameter>();33 public override void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root) { 34 IValueLookupParameter param = parameter as IValueLookupParameter; 32 35 param.ActualName = CastValue<string>(data.ActualName); 33 36 if (param.Value != null) 34 JsonItemConverter.Inject(param.Value, data);37 root.Inject(param.Value, data, root); 35 38 } 36 39 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17374 r17394 8 8 namespace HeuristicLab.JsonInterface { 9 9 public class ValueParameterConverter : ParameterBaseConverter { 10 public override int Priority => 2; 11 public override Type ConvertableType => typeof(IValueParameter); 10 12 11 public override void InjectData(IParameter parameter, JsonItem data ) {13 public override void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root) { 12 14 if (parameter.ActualValue == null && data.Value != null) 13 15 parameter.ActualValue = Instantiate(parameter.DataType); 14 JsonItemConverter.Inject(parameter.ActualValue, data);16 root.Inject(parameter.ActualValue, data, root); 15 17 } 16 18 17 public override JsonItem ExtractData(IParameter value) {18 JsonItem data = new JsonItem() { Name = value.Name };19 public override void Populate(IParameter value, JsonItem item, IJsonItemConverter root) { 20 item.Name = value.Name; 19 21 if (value.ActualValue != null) { 20 JsonItem tmp = JsonItemConverter.Extract(value.ActualValue);22 JsonItem tmp = root.Extract(value.ActualValue, root); 21 23 if(tmp.Name == "[OverridableParamName]") { 22 24 tmp.Name = value.Name; 23 data = tmp;25 JsonItem.Merge(item, tmp); 24 26 } 25 27 else 26 data.AddParameter(tmp);28 item.AddChilds(tmp); 27 29 } 28 return data;29 30 } 30 31 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17379 r17394 11 11 namespace HeuristicLab.JsonInterface { 12 12 13 public class IntRangeConverter : ValueRangeConverter<IntRange, IntValue, int> { } 14 public class DoubleRangeConverter : ValueRangeConverter<DoubleRange, DoubleValue, double> {} 13 public class IntRangeConverter : ValueRangeConverter<IntRange, IntValue, int> { 14 public override int Priority => 1; 15 public override Type ConvertableType => typeof(IntRange); 16 } 17 public class DoubleRangeConverter : ValueRangeConverter<DoubleRange, DoubleValue, double> { 18 public override int Priority => 1; 19 public override Type ConvertableType => typeof(DoubleRange); 20 } 15 21 16 public class ValueRangeConverter<RangeType, T, TType> : BaseConverter22 public abstract class ValueRangeConverter<RangeType, T, TType> : BaseConverter 17 23 where RangeType : StringConvertibleValueTuple<T, T> 18 24 where T : ValueTypeValue<TType>, IDeepCloneable, IStringConvertibleValue … … 21 27 private const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Instance; 22 28 23 public override JsonItem ExtractData(IItem value) {29 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 24 30 var field = value.GetType().GetField("values", Flags); 25 31 Tuple<T,T> tuple = (Tuple<T,T>)field.GetValue(value); 26 27 return new JsonItem() { 28 Name = "[OverridableParamName]", 29 Value = new object[] { tuple.Item1.Value, tuple.Item2.Value }, 30 Range = new object[] { GetMinValue(tuple.Item1.Value.GetType()), 31 GetMaxValue(tuple.Item2.Value.GetType()) } 32 }; 32 item.Name = "[OverridableParamName]"; 33 item.Value = new object[] { tuple.Item1.Value, tuple.Item2.Value }; 34 item.Range = new object[] { GetMinValue(tuple.Item1.Value.GetType()), GetMaxValue(tuple.Item2.Value.GetType()) }; 33 35 } 34 36 35 public override void InjectData(IItem item, JsonItem data ) {37 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) { 36 38 object[] arr = (object[])data.Value; 37 39 Tuple<T,T> tuple = new Tuple<T,T>(Instantiate<T>(arr[0]), Instantiate<T>(arr[1])); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r17374 r17394 9 9 10 10 namespace HeuristicLab.JsonInterface { 11 public class ValueTypeArrayConverter<ArrayType, T> : BaseConverter 11 12 public class IntArrayConverter : ValueTypeArrayConverter<IntArray, int> { 13 public override int Priority => 1; 14 public override Type ConvertableType => typeof(IntArray); 15 } 16 17 public class DoubleArrayConverter : ValueTypeArrayConverter<DoubleArray, double> { 18 public override int Priority => 1; 19 public override Type ConvertableType => typeof(DoubleArray); 20 } 21 22 public class PercentArrayConverter : ValueTypeArrayConverter<PercentArray, double> { 23 public override int Priority => 2; 24 public override Type ConvertableType => typeof(PercentArray); 25 } 26 27 public class BoolArrayConverter : ValueTypeArrayConverter<BoolArray, bool> { 28 public override int Priority => 1; 29 public override Type ConvertableType => typeof(BoolArray); 30 } 31 32 public abstract class ValueTypeArrayConverter<ArrayType, T> : BaseConverter 12 33 where ArrayType : ValueTypeArray<T> 13 34 where T : struct 14 35 { 15 public override void InjectData(IItem item, JsonItem data ) =>16 CopyArrayData( item.Cast<ArrayType>(), CastValue<T[]>(data.Value));36 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 37 CopyArrayData(((ArrayType)item), CastValue<T[]>(data.Value)); 17 38 18 public override JsonItem ExtractData(IItem value) => 19 new JsonItem() { 20 Name = "[OverridableParamName]", 21 Value = value.Cast<ArrayType>().CloneAsArray() 22 }; 39 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 40 item.Name = "[OverridableParamName]"; 41 item.Value = ((ArrayType)value).CloneAsArray(); 42 } 23 43 24 44 #region Helper -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r17379 r17394 9 9 10 10 namespace HeuristicLab.JsonInterface { 11 public class ValueTypeMatrixConverter<MatrixType, T> : BaseConverter 11 public class IntMatrixConverter : ValueTypeMatrixConverter<IntMatrix, int> { 12 public override int Priority => 1; 13 public override Type ConvertableType => typeof(IntMatrix); 14 } 15 16 public class DoubleMatrixConverter : ValueTypeMatrixConverter<DoubleMatrix, double> { 17 public override int Priority => 1; 18 public override Type ConvertableType => typeof(DoubleMatrix); 19 } 20 21 public class PercentMatrixConverter : ValueTypeMatrixConverter<PercentMatrix, double> { 22 public override int Priority => 2; 23 public override Type ConvertableType => typeof(PercentMatrix); 24 } 25 26 public class BoolMatrixConverter : ValueTypeMatrixConverter<BoolMatrix, bool> { 27 public override int Priority => 1; 28 public override Type ConvertableType => typeof(BoolMatrix); 29 } 30 31 public abstract class ValueTypeMatrixConverter<MatrixType, T> : BaseConverter 12 32 where MatrixType : ValueTypeMatrix<T> 13 33 where T : struct 14 34 { 15 public override void InjectData(IItem item, JsonItem data ) =>16 CopyMatrixData(item .Cast<MatrixType>(), data.Value);35 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 36 CopyMatrixData(item as MatrixType, data.Value); 17 37 18 public override JsonItem ExtractData(IItem value) => 19 new JsonItem() { 20 Name = "[OverridableParamName]", 21 Value = value.Cast<MatrixType>().CloneAsMatrix() 22 }; 38 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 39 item.Name = "[OverridableParamName]"; 40 item.Value = ((MatrixType)value).CloneAsMatrix(); 41 } 23 42 24 43 #region Helper -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs
r17374 r17394 8 8 9 9 namespace HeuristicLab.JsonInterface { 10 public class ValueTypeValueConverter<ValueType, T> : BaseConverter 10 11 public class IntValueConverter : ValueTypeValueConverter<IntValue, int> { 12 public override int Priority => 1; 13 public override Type ConvertableType => typeof(IntValue); 14 } 15 16 public class DoubleValueConverter : ValueTypeValueConverter<DoubleValue, double> { 17 public override int Priority => 1; 18 public override Type ConvertableType => typeof(DoubleValue); 19 } 20 21 public class PercentValueConverter : ValueTypeValueConverter<PercentValue, double> { 22 public override int Priority => 2; 23 public override Type ConvertableType => typeof(PercentValue); 24 } 25 26 public class BoolValueConverter : ValueTypeValueConverter<BoolValue, bool> { 27 public override int Priority => 1; 28 public override Type ConvertableType => typeof(BoolValue); 29 } 30 31 public class DateTimeValueConverter : ValueTypeValueConverter<DateTimeValue, DateTime> { 32 public override int Priority => 1; 33 public override Type ConvertableType => typeof(DateTimeValue); 34 } 35 36 public abstract class ValueTypeValueConverter<ValueType, T> : BaseConverter 11 37 where ValueType : ValueTypeValue<T> 12 38 where T : struct { 13 39 14 public override void InjectData(IItem item, JsonItem data ) =>15 item.Cast<ValueType>().Value = CastValue<T>(data.Value);40 public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) => 41 ((ValueType)item).Value = CastValue<T>(data.Value); 16 42 17 public override JsonItem ExtractData(IItem value) => 18 new JsonItem() { 19 Name = "[OverridableParamName]", 20 Value = value.Cast<ValueType>().Value, 21 Range = new object[] { GetMinValue(typeof(T)), GetMaxValue(typeof(T)) } 22 }; 43 public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) { 44 item.Name = "[OverridableParamName]"; 45 item.Value = ((ValueType)value).Value; 46 item.Range = new object[] { GetMinValue(typeof(T)), GetMaxValue(typeof(T)) }; 47 } 23 48 } 24 49 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17379 r17394 61 61 </ItemGroup> 62 62 <ItemGroup> 63 <Compile Include="Attributes\ConvertableAttribute.cs" />64 63 <Compile Include="Constants.cs" /> 65 64 <Compile Include="Converters\RegressionProblemDataConverter.cs" /> 66 65 <Compile Include="Converters\ValueLookupParameterConverter.cs" /> 67 66 <Compile Include="Converters\ValueRangeConverter.cs" /> 68 <Compile Include="CustomJsonWriter.cs" /> 69 <Compile Include="Extensions\ObjectExtensions.cs" /> 67 <Compile Include="SingleLineArrayJsonWriter.cs" /> 70 68 <Compile Include="Extensions\TypeExtensions.cs" /> 71 69 <Compile Include="JCGenerator.cs" /> 72 <Compile Include="J CInstantiator.cs" />70 <Compile Include="JsonTemplateInstantiator.cs" /> 73 71 <Compile Include="Converters\ConstrainedValueParameterConverter.cs" /> 74 72 <Compile Include="Converters\ParameterBaseConverter.cs" /> … … 76 74 <Compile Include="Converters\ValueParameterConverter.cs" /> 77 75 <Compile Include="Converters\EnumTypeConverter.cs" /> 78 <Compile Include="Converters\DummyConverter.cs" />79 76 <Compile Include="Converters\LookupParameterConverter.cs" /> 80 77 <Compile Include="Converters\MultiCheckedOperatorConverter.cs" /> … … 84 81 <Compile Include="Converters\ValueTypeMatrixConverter.cs" /> 85 82 <Compile Include="Converters\ValueTypeValueConverter.cs" /> 83 <Compile Include="JsonItemConverterFactory.cs" /> 86 84 <Compile Include="Plugin.cs" /> 87 85 <Compile Include="Properties\AssemblyInfo.cs" /> … … 89 87 <Compile Include="Interfaces\IJsonItemConverter.cs" /> 90 88 <Compile Include="JsonItemConverter.cs" /> 89 <Compile Include="UnsupportedJsonItem.cs" /> 91 90 </ItemGroup> 92 91 <ItemGroup> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItemConverter.cs
r17353 r17394 15 15 /// <param name="item">The IItem which get the data injected.</param> 16 16 /// <param name="data">The JsonItem with the saved values.</param> 17 void Inject(IItem item, JsonItem data );17 void Inject(IItem item, JsonItem data, IJsonItemConverter root); 18 18 19 19 /// <summary> … … 23 23 /// <param name="value">The IItem to extract infos.</param> 24 24 /// <returns>JsonItem with infos to reinitialise the IItem.</returns> 25 JsonItem Extract(IItem value); 25 JsonItem Extract(IItem value, IJsonItemConverter root); 26 27 Type ConvertableType { get; } 28 int Priority { get; } 26 29 } 27 30 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17379 r17394 35 35 // which have parameters aswell 36 36 AddInstantiableIItem(Constants.Algorithm, algorithm, genData); 37 //IsConvertable(algorithm, true);38 37 if (algorithm.Problem != null) // only when an problem exists 39 38 AddInstantiableIItem(Constants.Problem, algorithm.Problem, genData); … … 42 41 genData.Template[Constants.Parameters] = genData.JsonItems; 43 42 // serialize template and return string 44 return CustomJsonWriter.Serialize(genData.Template);43 return SingleLineArrayJsonWriter.Serialize(genData.Template); 45 44 } 46 45 47 46 #region Helper 48 private static bool IsConvertable(object obj, bool throwException = false) {49 bool tmp = ConvertableAttribute.IsConvertable(obj);50 if (throwException && tmp)51 throw new NotSupportedException($"Type {obj.GetType().GetPrettyName(false)} is not convertable!");52 return tmp;53 }54 47 55 48 private static void AddInstantiableIItem(string metaDataTagName, IItem item, GenData genData) { 56 49 JsonItem jsonItem = JsonItemConverter.Extract(item); 50 57 51 genData.Template[Constants.Metadata][metaDataTagName] = item.ItemName; 58 52 PopulateJsonItems(jsonItem, genData); … … 62 56 private static void PopulateJsonItems(JsonItem item, GenData genData) { 63 57 IEnumerable<JsonItem> tmpParameter = item.Children; 64 item.Children = null;65 58 66 59 if (item.Value != null || item.Range != null) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItem.cs
r17379 r17394 15 15 /// </summary> 16 16 public class JsonItem { 17 public class JsonItemValidator { 18 private IDictionary<int, bool> Cache = new Dictionary<int, bool>(); 19 private JsonItem Root { get; set; } 20 public JsonItemValidator(JsonItem root) { 21 Root = root; 22 } 17 23 18 #region Private Fields 19 private string name; 20 private object value; 21 private IEnumerable<object> range; 24 public bool Validate(ref IList<JsonItem> faultyItems) { 25 faultyItems = new List<JsonItem>(); 26 return ValidateHelper(Root, ref faultyItems); 27 } 28 29 private bool ValidateHelper(JsonItem item, ref IList<JsonItem> faultyItems) { 30 int hash = item.GetHashCode(); 31 if (Cache.TryGetValue(hash, out bool r)) 32 return r; 33 34 bool res = true; 35 if (item.Value != null && item.Range != null) 36 res = item.IsInRange(); 37 if (!res) faultyItems.Add(item); 38 Cache.Add(hash, res); 39 foreach (var child in item.Children) 40 res = res && ValidateHelper(child, ref faultyItems); 41 return res; 42 } 43 } 44 45 public virtual string Name { get; set; } 46 47 public virtual string Path { 48 get { 49 JsonItem tmp = Parent; 50 StringBuilder builder = new StringBuilder(this.Name); 51 while(tmp != null) { 52 builder.Insert(0, tmp.Name + "."); 53 tmp = tmp.Parent; 54 } 55 return builder.ToString(); 56 } 57 } 58 59 [JsonIgnore] 60 public virtual IList<JsonItem> Children { get; protected set; } 61 62 [JsonIgnore] 63 public virtual JsonItem Parent { get; set; } 64 65 public virtual object Value { get; set; } 66 67 public virtual IEnumerable<object> Range { get; set; } 68 69 public virtual string ActualName { get; set; } 70 71 #region Constructors 72 public JsonItem() { } 73 74 public JsonItem(IEnumerable<JsonItem> childs) { 75 AddChilds(childs); 76 } 22 77 #endregion 23 78 24 public string Name {25 get => name;26 set {27 if(Name != value) {28 string oldName = Name;29 name = value;30 // replace name in path if path != null31 if (Path != null) {32 var parts = Path.Split('.');33 parts[Array.IndexOf(parts, oldName)] = name;34 Path = string.Join(".", parts);35 } else36 Path = Name;37 38 UpdatePath();39 }40 }41 }42 public string Path { get; set; }43 public IList<JsonItem> Children { get; set; }44 public object Value {45 get => value;46 set {47 this.value = value;48 CheckConstraints();49 }50 }51 public IEnumerable<object> Range {52 get => range;53 set {54 range = value;55 CheckConstraints();56 }57 }58 public string ActualName { get; set; }59 79 60 80 #region Public Static Methods … … 62 82 target.Name = from.Name ?? target.Name; 63 83 target.Range = from.Range ?? target.Range; 64 target.Path = from.Path ?? target.Path;65 84 target.Value = from.Value ?? target.Value; 66 85 target.ActualName = from.ActualName ?? target.ActualName; … … 75 94 76 95 #region Public Methods 77 public void AddParameter(JsonItem item) { 96 public void AddChilds(params JsonItem[] childs) => 97 AddChilds(childs as IEnumerable<JsonItem>); 98 99 public void AddChilds(IEnumerable<JsonItem> childs) { 78 100 if (Children == null) 79 101 Children = new List<JsonItem>(); 80 Children.Add(item); 81 item.Path = $"{Path}.{item.Name}"; 82 item.UpdatePath(); 102 foreach (var child in childs) { 103 Children.Add(child); 104 child.Parent = this; 105 } 83 106 } 84 107 85 public void UpdatePath() { 86 if (Children != null) 87 UpdatePathHelper(Children); 88 } 108 public virtual JsonItemValidator GetValidator() => new JsonItemValidator(this); 89 109 #endregion 90 110 91 111 #region Helper 92 private void UpdatePathHelper(IEnumerable<JsonItem> items) {93 foreach (var item in items) {94 item.Path = $"{Path}.{item.Name}";95 item.UpdatePath();96 }97 }98 112 99 private void CheckConstraints() {100 if (Range != null && Value != null && !IsInRange())101 throw new ArgumentOutOfRangeException(nameof(Value), $"{nameof(Value)} is not in range.");102 }103 113 104 pr ivatebool IsInRange() {114 protected bool IsInRange() { 105 115 bool b1 = true, b2 = true; 106 116 if (Value is IEnumerable && !(Value is string)) { … … 117 127 } 118 128 119 pr ivatebool IsInRangeList(object value) {129 protected bool IsInRangeList(object value) { 120 130 foreach (var x in Range) 121 131 if (x.Equals(value)) return true; … … 123 133 } 124 134 125 pr ivatebool IsInNumericRange(object value) =>135 protected bool IsInNumericRange(object value) => 126 136 IsInNumericRange<ulong>(value) 127 137 || IsInNumericRange<uint>(value) … … 136 146 || (value is double && double.IsNaN((double)value)); 137 147 138 pr ivatebool IsInNumericRange<T>(object value) where T : IComparable {148 protected bool IsInNumericRange<T>(object value) where T : IComparable { 139 149 object min = Range.First(), max = Range.Last(); 140 150 return … … 153 163 return new JsonItem() { 154 164 Name = obj[nameof(Name)]?.ToString(), 155 Path = obj[nameof(Path)]?.ToString(),156 165 Value = val, 157 166 Range = obj[nameof(Range)]?.ToObject<object[]>(), -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs
r17379 r17394 12 12 namespace HeuristicLab.JsonInterface { 13 13 /// <summary> 14 /// Static class for handling json converters.14 /// Class for handling json converters. 15 15 /// </summary> 16 public static class JsonItemConverter { 16 public class JsonItemConverter : IJsonItemConverter { 17 18 #region Properties 19 private IDictionary<Type, IJsonItemConverter> Converters { get; set; } 20 = new Dictionary<Type, IJsonItemConverter>(); 17 21 18 private struct ConverterPriorityContainer { 19 public IJsonItemConverter Converter { get; set; } 20 public int Priority { get; set; } 21 } 22 private IDictionary<int, JsonItem> Cache { get; set; } 23 = new Dictionary<int, JsonItem>(); 22 24 23 private static IDictionary<Type, ConverterPriorityContainer> Converters { get; set; } 24 = new Dictionary<Type, ConverterPriorityContainer>(); 25 26 /// <summary> 27 /// Register a converter for a given type and priority. 28 /// </summary> 29 /// <param name="type">The type for which the converter will be selected.</param> 30 /// <param name="converter">The implemented converter.</param> 31 /// <param name="priority">The priority for the converter selection (when multiple converter match for a given type). Higher is better.</param> 32 public static void Register(Type type, IJsonItemConverter converter, int priority) { 33 if (!Converters.ContainsKey(type)) 34 Converters.Add(type, new ConverterPriorityContainer() { Converter = converter, Priority = priority }); 35 } 25 public int Priority => throw new NotImplementedException(); 36 26 37 public static void Register(string atticGuid, IJsonItemConverter converter, int priority) => 38 Register(new Guid(atticGuid), converter, priority); 39 40 public static void Register(Guid atticGuid, IJsonItemConverter converter, int priority) { 41 if (Mapper.StaticCache.TryGetType(atticGuid, out Type type)) { 42 Register(type, converter, priority); 43 } 44 } 45 46 public static void Register<T>(IJsonItemConverter converter, int priority) => 47 Register(typeof(T), converter, priority); 27 public Type ConvertableType => throw new NotImplementedException(); 28 #endregion 48 29 49 30 /// <summary> 50 /// Deregister a converter (same object has to be already registered). 51 /// </summary> 52 /// <param name="converter">Converter to deregister.</param> 53 public static void Deregister(IJsonItemConverter converter) { 54 var types = 55 Converters 56 .Where(x => x.Value.Converter.GetHashCode() == converter.GetHashCode()) 57 .Select(x => x.Key); 58 foreach (var x in types) 59 Converters.Remove(x); 60 } 61 62 /// <summary> 63 /// Get a converter for a specific type. 31 /// GetConverter a converter for a specific type. 64 32 /// </summary> 65 33 /// <param name="type">The type for which the converter will be selected.</param> 66 34 /// <returns>An IJsonItemConverter object.</returns> 67 public static IJsonItemConverter Get(Type type) {68 IList< ConverterPriorityContainer> possibleConverters = new List<ConverterPriorityContainer>();35 public IJsonItemConverter GetConverter(Type type) { 36 IList<IJsonItemConverter> possibleConverters = new List<IJsonItemConverter>(); 69 37 70 38 foreach (var x in Converters) … … 73 41 74 42 if(possibleConverters.Count > 0) { 75 ConverterPriorityContainer best = possibleConverters.First();43 IJsonItemConverter best = possibleConverters.First(); 76 44 foreach (var x in possibleConverters) { 77 45 if (x.Priority > best.Priority) 78 46 best = x; 79 47 } 80 return best .Converter;48 return best; 81 49 } 82 return new DummyConverter(); 50 return null; 51 } 52 53 public void Inject(IItem item, JsonItem data, IJsonItemConverter root) { 54 if(!Cache.ContainsKey(item.GetHashCode())) { 55 IJsonItemConverter converter = GetConverter(item.GetType()); 56 if(converter != null) converter.Inject(item, data, root); 57 } 83 58 } 84 59 85 internal static void Inject(IItem item, JsonItem data) => 86 Get(item.GetType()).Inject(item, data); 60 public JsonItem Extract(IItem item, IJsonItemConverter root) { 61 int hash = item.GetHashCode(); 62 if (Cache.TryGetValue(hash, out JsonItem val)) 63 return val; 64 else { 65 IJsonItemConverter converter = GetConverter(item.GetType()); 66 if (converter == null) return new UnsupportedJsonItem(); 67 JsonItem tmp = GetConverter(item.GetType()).Extract(item, root); 68 Cache.Add(hash, tmp); 69 return tmp; 70 } 71 } 72 73 public static void Inject(IItem item, JsonItem data) { 74 IJsonItemConverter c = JsonItemConverterFactory.Create(); 75 c.Inject(item, data, c); 76 } 87 77 88 internal static JsonItem Extract(IItem item) => 89 Get(item.GetType()).Extract(item); 90 78 public static JsonItem Extract(IItem item) { 79 IJsonItemConverter c = JsonItemConverterFactory.Create(); 80 return c.Extract(item, c); 81 } 91 82 92 83 /// <summary> 93 84 /// Static constructor for default converter configuration. 94 85 /// </summary> 95 static JsonItemConverter() { 96 Register<IntValue>(new ValueTypeValueConverter<IntValue, int>(), 1); 97 Register<DoubleValue>(new ValueTypeValueConverter<DoubleValue, double>(), 1); 98 Register<PercentValue>(new ValueTypeValueConverter<PercentValue, double>(), 2); 99 Register<BoolValue>(new ValueTypeValueConverter<BoolValue, bool>(), 1); 100 Register<DateTimeValue>(new ValueTypeValueConverter<DateTimeValue, DateTime>(), 1); 101 Register<StringValue>(new StringValueConverter(), 1); 102 103 Register<IntArray>(new ValueTypeArrayConverter<IntArray, int>(), 1); 104 Register<DoubleArray>(new ValueTypeArrayConverter<DoubleArray, double>(), 1); 105 Register<PercentArray>(new ValueTypeArrayConverter<PercentArray, double>(), 2); 106 Register<BoolArray>(new ValueTypeArrayConverter<BoolArray, bool>(), 1); 107 108 Register<IntMatrix>(new ValueTypeMatrixConverter<IntMatrix, int>(), 1); 109 Register<DoubleMatrix>(new ValueTypeMatrixConverter<DoubleMatrix, double>(), 1); 110 Register<PercentMatrix>(new ValueTypeMatrixConverter<PercentMatrix, double>(), 2); 111 Register<BoolMatrix>(new ValueTypeMatrixConverter<BoolMatrix, bool>(), 1); 112 113 Register<DoubleRange>(new DoubleRangeConverter(), 1); 114 Register<IntRange>(new IntRangeConverter(), 1); 115 116 Register(typeof(EnumValue<>), new EnumTypeConverter(), 1); 117 118 Register<IValueParameter>(new ValueParameterConverter(), 2); 119 Register<IParameterizedItem>(new ParameterizedItemConverter(), 2); 120 Register<ILookupParameter>(new LookupParameterConverter(), 3); 121 Register<IValueLookupParameter>(new ValueLookupParameterConverter(), 4); 122 123 Register(typeof(IConstrainedValueParameter<>), new ConstrainedValueParameterConverter(), 3); 124 Register(typeof(ICheckedMultiOperator<>), new MultiCheckedOperatorConverter(), 3); 125 126 Register("EE612297-B1AF-42D2-BF21-AF9A2D42791C", new RegressionProblemDataConverter(), 20); 86 internal JsonItemConverter(IDictionary<Type, IJsonItemConverter> converters) { 87 Converters = converters; 127 88 } 128 89 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r17393 r17394 11 11 using HeuristicLab.Data; 12 12 using HeuristicLab.Optimization; 13 using HeuristicLab.SequentialEngine;14 13 using Newtonsoft.Json.Linq; 15 14 … … 18 17 /// Static class to instantiate an IAlgorithm object with a json interface template and config. 19 18 /// </summary> 20 public static class J CInstantiator {19 public static class JsonTemplateInstantiator { 21 20 private struct InstData { 22 21 public JToken Template { get; set; } 23 22 public JArray Config { get; set; } 24 23 public IDictionary<string, JsonItem> Objects { get; set; } 25 public IDictionary<string, JsonItem> ResolvedItems { get; set; }26 24 } 27 25 … … 34 32 public static IAlgorithm Instantiate(string templateFile, string configFile = "") { 35 33 InstData instData = new InstData() { 36 Objects = new Dictionary<string, JsonItem>(), 37 ResolvedItems = new Dictionary<string, JsonItem>() 34 Objects = new Dictionary<string, JsonItem>() 38 35 }; 39 36 … … 54 51 // collect all parameterizedItems from template 55 52 CollectParameterizedItems(instData); 56 57 // rebuild tree with paths 58 RebuildTree(instData); 59 53 60 54 // if config != null -> merge Template and Config 61 55 if (instData.Config != null) … … 79 73 private static void CollectParameterizedItems(InstData instData) { 80 74 foreach (JObject item in instData.Template[Constants.Parameters]) { 81 JsonItem data = JsonItem.BuildJsonItem(item); 82 instData.Objects.Add(data.Path, data); 83 } 84 } 85 86 private static JsonItem RebuildTreeHelper(IList<JsonItem> col, string name) { 87 JsonItem target = null; 88 foreach (var val in col) { 89 if (val.Name == name) 90 target = val; 91 } 92 if (target == null) { 93 target = new JsonItem() { 94 Name = name, 95 Path = name, 96 Children = new List<JsonItem>() 97 }; 98 col.Add(target); 99 } 100 return target; 101 } 102 103 // rebuilds item tree with splitting paths of each jsonitem 104 private static void RebuildTree(InstData instData) { 105 List<JsonItem> values = new List<JsonItem>(); 106 foreach (var x in instData.Objects) { 107 string[] pathParts = x.Key.Split('.'); 108 JsonItem target = RebuildTreeHelper(values, pathParts[0]); 109 110 for (int i = 1; i < pathParts.Length; ++i) { 111 target = RebuildTreeHelper(target.Children, pathParts[i]); 75 string[] pathParts = item.Property("Path").Value.ToString().Split('.'); 76 77 // rebuilds object tree 78 JsonItem parent = null; 79 StringBuilder partialPath = new StringBuilder(); 80 for(int i = 0; i < pathParts.Length-1; ++i) { 81 partialPath.Append(pathParts[i]); 82 JsonItem tmp = null; 83 if (instData.Objects.TryGetValue(partialPath.ToString(), out JsonItem value)) { 84 tmp = value; 85 } else { 86 tmp = new JsonItem() { Name = pathParts[i] }; 87 if (parent != null) parent.AddChilds(tmp); 88 instData.Objects.Add(partialPath.ToString(), tmp); 89 } 90 partialPath.Append("."); 91 parent = tmp; 112 92 } 113 93 114 JsonItem.Merge(target, x.Value); 115 } 116 foreach(var val in values) { 117 instData.ResolvedItems.Add(val.Name, val); 94 JsonItem data = JsonItem.BuildJsonItem(item); 95 parent.AddChilds(data); 96 instData.Objects.Add(data.Path, data); 118 97 } 119 98 } … … 135 114 private static JsonItem GetData(string key, InstData instData) 136 115 { 137 if (instData. ResolvedItems.TryGetValue(key, out JsonItem value))116 if (instData.Objects.TryGetValue(key, out JsonItem value)) 138 117 return value; 139 118 else -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/SingleLineArrayJsonWriter.cs
r17393 r17394 8 8 /// It collapses arrays into a single line. 9 9 /// </summary> 10 internal class CustomJsonWriter : JsonTextWriter {10 internal class SingleLineArrayJsonWriter : JsonTextWriter { 11 11 private bool isRangeArray = false; 12 12 public override void WriteStartArray() { … … 32 32 } 33 33 34 public CustomJsonWriter(TextWriter writer) : base(writer) { }34 public SingleLineArrayJsonWriter(TextWriter writer) : base(writer) { } 35 35 36 36 public static string Serialize(JToken token) { 37 37 JsonSerializer serializer = new JsonSerializer(); 38 38 StringWriter sw = new StringWriter(); 39 CustomJsonWriter writer = new CustomJsonWriter(sw);39 SingleLineArrayJsonWriter writer = new SingleLineArrayJsonWriter(sw); 40 40 writer.Formatting = Formatting.Indented; 41 41 serializer.Serialize(writer, token); -
branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs
r17379 r17394 46 46 47 47 File.WriteAllText(@"C:\Workspace\Template.json", JCGenerator.GenerateTemplate(alg)); 48 J CInstantiator.Instantiate(@"C:\Workspace\Template.json");48 JsonTemplateInstantiator.Instantiate(@"C:\Workspace\Template.json"); 49 49 /* 50 50 List<ICommandLineArgument> arguments = new List<ICommandLineArgument>();
Note: See TracChangeset
for help on using the changeset viewer.