Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/07/20 16:25:39 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • deleted: ConvertableAttribute, DummyConverter, ObjectExtensions
  • renamed: CustomJsonWriter -> SingleLineArrayJsonWriter, JCInstantiator -> JsonTemplateInstantiator
  • added: JsonItemConverterFactory, UnsupportedJsonItem
  • IJsonItemConverter:
    • added two new properties: Priority and ConvertableType -> because converters are automatically collected by plugin infrastructure now
    • Extract, Inject references a root converter now -> typically an instance of JsonItemConverter -> to prevent cycles
  • JsonItemConverter:
    • now implements the interface IJsonItemConverter
    • is now a dynamic class
    • is only instantiable with an factory (JsonItemConverterFactory)
    • still has the old (but now public) static methods Extract and Inject (without ref param IJsonItemConverter root) -> creates instance with factory and calls methods of instance
    • removed register and unregister methods, because the factory collects all converters automatically now (on first call of Create)
    • has cycle detection for Extract and Inject
    • renamed method Get to GetConverter
File:
1 edited

Legend:

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

    r17379 r17394  
    88namespace HeuristicLab.JsonInterface {
    99  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
    1219      object actualValue = null;
    1320      IEnumerable<object> actualRange = null;
    1421      if(param.Value != null) {
    15         JsonItem tmp = JsonItemConverter.Extract(param.Value);
     22        JsonItem tmp = root.Extract(param.Value, root);
     23        tmp.Parent = item;
    1624        actualValue = tmp.Value;
    1725        actualRange = tmp.Range;
     
    1927        actualRange = new object[] { GetMinValue(param.DataType), GetMaxValue(param.DataType) };
    2028      }
    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;
    2831    }
    2932
    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;
    3235      param.ActualName = CastValue<string>(data.ActualName);
    3336      if (param.Value != null)
    34         JsonItemConverter.Inject(param.Value, data);
     37        root.Inject(param.Value, data, root);
    3538    }
    3639  }
Note: See TracChangeset for help on using the changeset viewer.