Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs @ 17394

Last change on this file since 17394 was 17394, checked in by dpiringe, 4 years ago

#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 size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Core;
8using HeuristicLab.Data;
9
10namespace HeuristicLab.JsonInterface {
11  public class RegressionProblemDataConverter : BaseConverter {
12    private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
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) {     
17      dynamic val = (dynamic)value;
18      object dataset = (object)val.Dataset;
19      dynamic targetVariable = val.TargetVariable;
20      FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
21      // TODO: aufteilen in trainings und test daten abschnitte
22      item.AddChilds(new JsonItem() {
23        Name = "Dataset",
24        Value = dataInfo.GetValue(dataset)
25      });
26
27      IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
28      item.AddChilds(new JsonItem() {
29        Name = "TargetVariable",
30        Value = (object)targetVariable,
31        Range = variables.Select(x => x.Value)
32      });
33
34
35      item.AddChilds(new JsonItem() {
36        Name = "AllowedInputVariables",
37        Value = (object)val.AllowedInputVariables,
38        Range = variables.Select(x => x.Value)
39      });
40    }
41
42    public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) {
43      // TODO: inject data
44      throw new NotImplementedException();
45    }
46  }
47}
Note: See TracBrowser for help on using the repository browser.