Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/19 14:36:32 (5 years ago)
Author:
dpiringe
Message:

#3026: renamed Component to JsonItem

Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/BaseConverter.cs

    r17281 r17283  
    1010  public abstract class BaseConverter : IJsonItemConverter
    1111  {
    12     public Component Extract(IItem value) {
    13       Component data = ExtractData(value);
     12    public JsonItem Extract(IItem value) {
     13      JsonItem data = ExtractData(value);
    1414      data.Name = String.IsNullOrEmpty(data.Name) ? value.ItemName : data.Name;
    1515      return data;
    1616    }
    1717
    18     public void Inject(IItem item, Component data) {
     18    public void Inject(IItem item, JsonItem data) {
    1919      if(data.Reference != null) {
    20         Component.Merge(data, data.Reference);
     20        JsonItem.Merge(data, data.Reference);
    2121      }
    2222      InjectData(item, data);
    2323    }
    2424
    25     public abstract void InjectData(IItem item, Component data);
    26     public abstract Component ExtractData(IItem value);
     25    public abstract void InjectData(IItem item, JsonItem data);
     26    public abstract JsonItem ExtractData(IItem value);
    2727
    2828    #region Helper
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ConstrainedValueParameterConverter.cs

    r17281 r17283  
    88namespace HeuristicLab.Manufacture {
    99  public class ConstrainedValueParameterConverter : ParameterBaseConverter {
    10     public override void InjectData(IParameter parameter, Component data) {
     10    public override void InjectData(IParameter parameter, JsonItem data) {
    1111      foreach (var x in parameter.Cast<dynamic>().ValidValues)
    1212        if (x.GetType().Name == CastValue<string>(data.Default))
     
    1717    }
    1818
    19     public override Component ExtractData(IParameter value) =>
    20       new Component() {
     19    public override JsonItem ExtractData(IParameter value) =>
     20      new JsonItem() {
    2121        Name = value.Name,
    2222        Default = value.ActualValue?.GetType().Name,
     
    3333    }
    3434    // id = kombi aus path + default
    35     private IList<Component> GetParameterizedChilds(IParameter value) {
    36       List<Component> list = new List<Component>();
     35    private IList<JsonItem> GetParameterizedChilds(IParameter value) {
     36      List<JsonItem> list = new List<JsonItem>();
    3737      var values = value.Cast<dynamic>().ValidValues;
    3838      foreach(var x in values) {
    3939        if (x is IParameterizedItem) {
    40           Component tmp = JsonItemConverter.Extract(x);
     40          JsonItem tmp = JsonItemConverter.Extract(x);
    4141          tmp.PrependPath(value.Name);
    4242          list.Add(tmp);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/DummyConverter.cs

    r17281 r17283  
    88namespace HeuristicLab.Manufacture {
    99  public class DummyConverter : BaseConverter {
    10     public override void InjectData(IItem item, Component data) {
     10    public override void InjectData(IItem item, JsonItem data) {
    1111      // do nothing because the instance already exists and
    1212      // there are no values to inject
    1313    }
    1414
    15     public override Component ExtractData(IItem value) =>
    16       new Component() { Default = value.GetType().Name };
     15    public override JsonItem ExtractData(IItem value) =>
     16      new JsonItem() { Default = value.GetType().Name };
    1717  }
    1818}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/EnumTypeConverter.cs

    r17281 r17283  
    99namespace HeuristicLab.Manufacture {
    1010  public class EnumTypeConverter : BaseConverter {
    11     public override void InjectData(IItem item, Component data) =>
     11    public override void InjectData(IItem item, JsonItem data) =>
    1212      item.Cast<dynamic>().Value = Enum.Parse(
    1313        item.GetType().GenericTypeArguments.First(),
    1414        CastValue<string>(data.Default));
    1515
    16     public override Component ExtractData(IItem value) {
    17       Component data = new Component();
     16    public override JsonItem ExtractData(IItem value) {
     17      JsonItem data = new JsonItem();
    1818      object val = ((dynamic)value).Value;
    1919      Type enumType = val.GetType();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/LookupParameterConverter.cs

    r17281 r17283  
    88namespace HeuristicLab.Manufacture {
    99  public class LookupParameterConverter : ParameterBaseConverter {
    10     public override Component ExtractData(IParameter value) {
    11       return new Component() { Name = value.Name };
     10    public override JsonItem ExtractData(IParameter value) {
     11      return new JsonItem() { Name = value.Name };
    1212    }
    1313
    14     public override void InjectData(IParameter parameter, Component data) {
     14    public override void InjectData(IParameter parameter, JsonItem data) {
    1515     
    1616    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/MultiCheckedOperatorConverter.cs

    r17281 r17283  
    88namespace HeuristicLab.Manufacture {
    99  public class MultiCheckedOperatorConverter : ParameterizedItemConverter {
    10     public override Component ExtractData(IItem value) {
    11       Component data = base.ExtractData(value);
     10    public override JsonItem ExtractData(IItem value) {
     11      JsonItem data = base.ExtractData(value);
    1212
    1313      data.Default = value.GetType().Name;
    14       data.Operators = new List<Component>();
    15       /*
    16       if (data.ParameterizedItems == null)
    17         data.ParameterizedItems = new List<Component>();
    18       data.ParameterizedItems.Add(data);
    19       */
     14      data.Operators = new List<JsonItem>();
    2015      dynamic val = value.Cast<dynamic>();
    2116      foreach (var op in val.Operators) {
    22         data.Operators.Add(new Component() {
     17        data.Operators.Add(new JsonItem() {
    2318          Name = op.Name,
    2419          Default = val.Operators.ItemChecked(op),
     
    3025    }
    3126
    32     public override void InjectData(IItem item, Component data) {
     27    public override void InjectData(IItem item, JsonItem data) {
    3328      base.InjectData(item, data);
    3429
     
    3934    }
    4035
    41     private bool GetOperatorState(string name, Component data) {
     36    private bool GetOperatorState(string name, JsonItem data) {
    4237      foreach(var op in data.Operators) {
    4338        if (op.Name == name) return op.Default.Cast<bool>();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ParameterBaseConverter.cs

    r17281 r17283  
    88namespace HeuristicLab.Manufacture {
    99  public abstract class ParameterBaseConverter : BaseConverter {
    10     public override Component ExtractData(IItem value) {
     10    public override JsonItem ExtractData(IItem value) {
    1111      IParameter param = value.Cast<IParameter>();
    12       Component comp = ExtractData(param);
     12      JsonItem comp = ExtractData(param);
    1313      //comp.Path = value.Cast<IParameter>().ActualValue?.ItemName;
    1414      /*comp.Path = value.Cast<IParameter>().Name + "." + comp.Path;
     
    2020      return comp;
    2121    }
    22     public abstract Component ExtractData(IParameter value);
     22    public abstract JsonItem ExtractData(IParameter value);
    2323
    24     public override void InjectData(IItem item, Component data) => InjectData(item.Cast<IParameter>(), data);
     24    public override void InjectData(IItem item, JsonItem data) => InjectData(item.Cast<IParameter>(), data);
    2525
    26     public abstract void InjectData(IParameter parameter, Component data);
     26    public abstract void InjectData(IParameter parameter, JsonItem data);
    2727  }
    2828}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ParameterizedItemConverter.cs

    r17281 r17283  
    22using System.Collections.Generic;
    33using System.Linq;
    4 using System.Text;
     4using System.Text;JsonItem obj
    55using System.Threading.Tasks;
    66using HeuristicLab.Core;
     
    99{
    1010  public class ParameterizedItemConverter : BaseConverter {
    11     public override void InjectData(IItem item, Component data) {
     11    public override void InjectData(IItem item, JsonItem data) {
    1212      IParameterizedItem pItem = item.Cast<IParameterizedItem>();
    1313
     
    1919    }
    2020
    21     public override Component ExtractData(IItem value) {
    22       Component obj = new Component();
    23       obj.Name = value.ItemName;
    24       obj.Type = value.GetType().AssemblyQualifiedName;
    25       obj.Path = value.ItemName;
     21    public override JsonItem ExtractData(IItem value) {
     22      JsonItem item = new JsonItem();
     23      item.Name = value.ItemName;
     24      item.Type = value.GetType().AssemblyQualifiedName;
     25      item.Path = value.ItemName;
    2626
    2727      foreach (var param in value.Cast<IParameterizedItem>().Parameters) {
    28         Component data = JsonItemConverter.Extract(param);
     28        JsonItem data = JsonItemConverter.Extract(param);
    2929        data.Name = param.Name;
    3030        data.Path = param.Name;
    31         data.PrependPath(obj.Path);
     31        data.PrependPath(item.Path);
    3232        data.UpdatePaths();
    3333       
    34         if (obj.Parameters == null)
    35           obj.Parameters = new List<Component>();
    36         obj.Parameters.Add(data);
     34        if (item.Parameters == null)
     35          item.Parameters = new List<JsonItem>();
     36        item.Parameters.Add(data);
    3737      }
    38       return obj;
     38      return item;
    3939    }
    4040  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/StringValueConverter.cs

    r17281 r17283  
    99namespace HeuristicLab.Manufacture {
    1010  public class StringValueConverter : BaseConverter {
    11     public override void InjectData(IItem item, Component data) =>
     11    public override void InjectData(IItem item, JsonItem data) =>
    1212      item.Cast<StringValue>().Value = CastValue<string>(data.Default);
    1313
    14     public override Component ExtractData(IItem value) =>
    15       new Component() {
     14    public override JsonItem ExtractData(IItem value) =>
     15      new JsonItem() {
    1616        Default = value.Cast<StringValue>().Value
    1717      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueParameterConverter.cs

    r17281 r17283  
    99  public class ValueParameterConverter : ParameterBaseConverter {
    1010
    11     public override void InjectData(IParameter parameter, Component data) =>
     11    public override void InjectData(IParameter parameter, JsonItem data) =>
    1212      JsonItemConverter.Inject(parameter.ActualValue, data);
    1313
    14     public override Component ExtractData(IParameter value) {
    15       Component data = null;
     14    public override JsonItem ExtractData(IParameter value) {
     15      JsonItem data = null;
    1616      if (value.ActualValue == null)
    17         data = new Component();
     17        data = new JsonItem();
    1818      else
    1919        data = JsonItemConverter.Extract(value.ActualValue);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeArrayConverter.cs

    r17281 r17283  
    1313    where T : struct
    1414  {
    15     public override void InjectData(IItem item, Component data) =>
     15    public override void InjectData(IItem item, JsonItem data) =>
    1616      CopyArrayData(item.Cast<ArrayType>(), CastValue<T[]>(data.Default));
    1717
    18     public override Component ExtractData(IItem value) =>
    19       new Component() {
     18    public override JsonItem ExtractData(IItem value) =>
     19      new JsonItem() {
    2020        Default = value.Cast<ArrayType>().CloneAsArray()
    2121      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeMatrixConverter.cs

    r17281 r17283  
    1313    where T : struct
    1414  {
    15     public override void InjectData(IItem item, Component data) =>
     15    public override void InjectData(IItem item, JsonItem data) =>
    1616      CopyMatrixData(item.Cast<MatrixType>(), CastValue<T[,]>(data.Default));
    1717
    18     public override Component ExtractData(IItem value) =>
    19       new Component() {
     18    public override JsonItem ExtractData(IItem value) =>
     19      new JsonItem() {
    2020        Default = value.Cast<MatrixType>().CloneAsMatrix()
    2121      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeValueConverter.cs

    r17281 r17283  
    1212    where T : struct {
    1313
    14     public override void InjectData(IItem item, Component data) =>
     14    public override void InjectData(IItem item, JsonItem data) =>
    1515      item.Cast<ValueType>().Value = CastValue<T>(data.Default);
    1616
    17     public override Component ExtractData(IItem value) =>
    18       new Component() {
     17    public override JsonItem ExtractData(IItem value) =>
     18      new JsonItem() {
    1919        Default = value.Cast<ValueType>().Value,
    2020        Range = new object[] { GetMinValue(), GetMaxValue() }
Note: See TracChangeset for help on using the changeset viewer.