Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/07/20 16:25:39 (5 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/RegressionProblemDataConverter.cs

    r17379 r17394  
    1111  public class RegressionProblemDataConverter : BaseConverter {
    1212    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) {     
    1917      dynamic val = (dynamic)value;
    2018      object dataset = (object)val.Dataset;
     
    2220      FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
    2321      // TODO: aufteilen in trainings und test daten abschnitte
    24       item.Children.Add(new JsonItem() {
     22      item.AddChilds(new JsonItem() {
    2523        Name = "Dataset",
    26         Value = dataInfo.GetValue(dataset),
    27         Path = "Dataset"
     24        Value = dataInfo.GetValue(dataset)
    2825      });
    2926
    3027      IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
    31       item.Children.Add(new JsonItem() {
     28      item.AddChilds(new JsonItem() {
    3229        Name = "TargetVariable",
    3330        Value = (object)targetVariable,
    34         Range = variables.Select(x => x.Value),
    35         Path = "TargetVariable"
     31        Range = variables.Select(x => x.Value)
    3632      });
    3733
    3834
    39       item.Children.Add(new JsonItem() {
     35      item.AddChilds(new JsonItem() {
    4036        Name = "AllowedInputVariables",
    4137        Value = (object)val.AllowedInputVariables,
    42         Range = variables.Select(x => x.Value),
    43         Path = "AllowedInputVariables"
     38        Range = variables.Select(x => x.Value)
    4439      });
    45 
    46       item.UpdatePath();
    47 
    48       return item;
    4940    }
    5041
    51     public override void InjectData(IItem item, JsonItem data) {
     42    public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) {
    5243      // TODO: inject data
    5344      throw new NotImplementedException();
Note: See TracChangeset for help on using the changeset viewer.