Changeset 17281


Ignore:
Timestamp:
10/01/19 13:45:03 (2 weeks ago)
Author:
dpiringe
Message:

#3026: renamed Transformers -> ...Transformer to ...Converter, ITypeTransformer to IJsonItemConverter, Transformer to JsonItemConverter

Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture
Files:
1 added
2 deleted
2 edited
13 copied
2 moved

Legend:

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

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public abstract class BaseTransformer : ITypeTransformer
     10  public abstract class BaseConverter : IJsonItemConverter
    1111  {
    1212    public Component Extract(IItem value) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ConstrainedValueParameterConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public class ConstrainedValueParameterTransformer : ParameterBaseTransformer {
     9  public class ConstrainedValueParameterConverter : ParameterBaseConverter {
    1010    public override void InjectData(IParameter parameter, Component data) {
    1111      foreach (var x in parameter.Cast<dynamic>().ValidValues)
     
    1414
    1515      if (parameter.ActualValue is IParameterizedItem && data.Reference != null)
    16         Transformer.Inject(parameter.ActualValue, data.Reference);
     16        JsonItemConverter.Inject(parameter.ActualValue, data.Reference);
    1717    }
    1818
     
    3838      foreach(var x in values) {
    3939        if (x is IParameterizedItem) {
    40           Component tmp = Transformer.Extract(x);
     40          Component tmp = JsonItemConverter.Extract(x);
    4141          tmp.PrependPath(value.Name);
    4242          list.Add(tmp);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/DummyConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public class DummyTransformer : BaseTransformer {
     9  public class DummyConverter : BaseConverter {
    1010    public override void InjectData(IItem item, Component data) {
    1111      // do nothing because the instance already exists and
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/EnumTypeConverter.cs

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public class EnumTypeTransformer : BaseTransformer {
     10  public class EnumTypeConverter : BaseConverter {
    1111    public override void InjectData(IItem item, Component data) =>
    1212      item.Cast<dynamic>().Value = Enum.Parse(
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/LookupParameterConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public class LookupParameterTransformer : ParameterBaseTransformer {
     9  public class LookupParameterConverter : ParameterBaseConverter {
    1010    public override Component ExtractData(IParameter value) {
    1111      return new Component() { Name = value.Name };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/MultiCheckedOperatorConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public class MultiCheckedOperatorTransformer : ParameterizedItemTransformer {
     9  public class MultiCheckedOperatorConverter : ParameterizedItemConverter {
    1010    public override Component ExtractData(IItem value) {
    1111      Component data = base.ExtractData(value);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ParameterBaseConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public abstract class ParameterBaseTransformer : BaseTransformer {
     9  public abstract class ParameterBaseConverter : BaseConverter {
    1010    public override Component ExtractData(IItem value) {
    1111      IParameter param = value.Cast<IParameter>();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ParameterizedItemConverter.cs

    r17280 r17281  
    88namespace HeuristicLab.Manufacture
    99{
    10   public class ParameterizedItemTransformer : BaseTransformer {
     10  public class ParameterizedItemConverter : BaseConverter {
    1111    public override void InjectData(IItem item, Component data) {
    1212      IParameterizedItem pItem = item.Cast<IParameterizedItem>();
     
    1515        foreach (var sp in data.Parameters)
    1616          if (pItem.Parameters.TryGetValue(sp.Name, out IParameter param))
    17             Transformer.Inject(param, sp);
     17            JsonItemConverter.Inject(param, sp);
    1818      }
    1919    }
     
    2626
    2727      foreach (var param in value.Cast<IParameterizedItem>().Parameters) {
    28         Component data = Transformer.Extract(param);
     28        Component data = JsonItemConverter.Extract(param);
    2929        data.Name = param.Name;
    3030        data.Path = param.Name;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/StringValueConverter.cs

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public class StringValueTransformer : BaseTransformer {
     10  public class StringValueConverter : BaseConverter {
    1111    public override void InjectData(IItem item, Component data) =>
    1212      item.Cast<StringValue>().Value = CastValue<string>(data.Default);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueParameterConverter.cs

    r17280 r17281  
    77
    88namespace HeuristicLab.Manufacture {
    9   public class ValueParameterTransformer : ParameterBaseTransformer {
     9  public class ValueParameterConverter : ParameterBaseConverter {
    1010
    1111    public override void InjectData(IParameter parameter, Component data) =>
    12       Transformer.Inject(parameter.ActualValue, data);
     12      JsonItemConverter.Inject(parameter.ActualValue, data);
    1313
    1414    public override Component ExtractData(IParameter value) {
     
    1717        data = new Component();
    1818      else
    19         data = Transformer.Extract(value.ActualValue);
     19        data = JsonItemConverter.Extract(value.ActualValue);
    2020      data.Name = value.Name;
    2121      return data;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeArrayConverter.cs

    r17280 r17281  
    99
    1010namespace HeuristicLab.Manufacture {
    11   public class ValueTypeArrayTransformer<ArrayType, T> : BaseTransformer
     11  public class ValueTypeArrayConverter<ArrayType, T> : BaseConverter
    1212    where ArrayType : ValueTypeArray<T>
    1313    where T : struct
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeMatrixConverter.cs

    r17280 r17281  
    99
    1010namespace HeuristicLab.Manufacture {
    11   public class ValueTypeMatrixTransformer<MatrixType, T> : BaseTransformer
     11  public class ValueTypeMatrixConverter<MatrixType, T> : BaseConverter
    1212    where MatrixType : ValueTypeMatrix<T>
    1313    where T : struct
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Converters/ValueTypeValueConverter.cs

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public class ValueTypeValueTransformer<ValueType, T> : BaseTransformer
     10  public class ValueTypeValueConverter<ValueType, T> : BaseConverter
    1111    where ValueType : ValueTypeValue<T>
    1212    where T : struct {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Interfaces/IJsonItemConverter.cs

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public interface ITypeTransformer {
     10  public interface IJsonItemConverter {
    1111    /// <summary>
    1212    /// Extracts all infos out of an IItem to create a Component.
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/JCGenerator.cs

    r17280 r17281  
    5555    public string GenerateTemplate(IAlgorithm algorithm, IProblem problem, params string[] freeParameters) {
    5656      algorithm.Problem = problem;
    57       Component algorithmData = Transformer.Extract(algorithm);
    58       Component problemData = Transformer.Extract(problem);
     57      Component algorithmData = JsonItemConverter.Extract(algorithm);
     58      Component problemData = JsonItemConverter.Extract(problem);
    5959      PopulateJsonItems(algorithmData);
    6060      PopulateJsonItems(problemData);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/JCInstantiator.cs

    r17280 r17281  
    3131      algorithm.Problem = problem;
    3232
    33       Transformer.Inject(algorithm, algorithmData);
    34       Transformer.Inject(algorithm, problemData);
     33      JsonItemConverter.Inject(algorithm, algorithmData);
     34      JsonItemConverter.Inject(algorithm, problemData);
    3535
    3636      return algorithm;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/JsonItemConverter.cs

    r17280 r17281  
    88
    99namespace HeuristicLab.Manufacture {
    10   public static class Transformer {
    11     private static IDictionary<Type, ITypeTransformer> transformers = new Dictionary<Type, ITypeTransformer>();
     10  public static class JsonItemConverter {
     11    private static IDictionary<Type, IJsonItemConverter> transformers = new Dictionary<Type, IJsonItemConverter>();
    1212   
    13     public static void Register(Type type, ITypeTransformer transformer) { // TODO: explizit
     13    public static void Register(Type type, IJsonItemConverter transformer) { // TODO: explizit
    1414      if (!transformers.ContainsKey(type))
    1515        transformers.Add(type, transformer);
     
    1717
    1818
    19     public static void Register<T>(ITypeTransformer transformer) => Register(typeof(T), transformer);
     19    public static void Register<T>(IJsonItemConverter transformer) => Register(typeof(T), transformer);
    2020
    21     public static IEnumerable<ITypeTransformer> Get(Type type) {
    22       IList<KeyValuePair<Type, ITypeTransformer>> possibleTransformers = new List<KeyValuePair<Type, ITypeTransformer>>();
     21    public static IEnumerable<IJsonItemConverter> Get(Type type) {
     22      IList<KeyValuePair<Type, IJsonItemConverter>> possibleTransformers = new List<KeyValuePair<Type, IJsonItemConverter>>();
    2323
    2424
     
    3030
    3131      if(possibleTransformers.Count > 0) {
    32         ITypeTransformer nearest = possibleTransformers.First().Value;
     32        IJsonItemConverter nearest = possibleTransformers.First().Value;
    3333        int nearestDistance = -1;
    3434        foreach (var x in possibleTransformers) {
     
    3939          }
    4040        }
    41         return new ITypeTransformer[] { nearest };
     41        return new IJsonItemConverter[] { nearest };
    4242        /*
    4343        return possibleTransformers.OrderBy(x => {
     
    4646        */
    4747      }
    48       return new ITypeTransformer[] { new DummyTransformer() };
     48      return new IJsonItemConverter[] { new DummyConverter() };
    4949    }
    5050
    5151    internal static void Inject(IItem item, Component data) {
    52       IEnumerable<ITypeTransformer> arr = Get(item.GetType());
     52      IEnumerable<IJsonItemConverter> arr = Get(item.GetType());
    5353      foreach (var transformer in arr)
    5454        transformer.Inject(item, data);
     
    5656
    5757    internal static Component Extract(IItem item) {
    58       IEnumerable<ITypeTransformer> arr = Get(item.GetType());
     58      IEnumerable<IJsonItemConverter> arr = Get(item.GetType());
    5959      Component data = new Component();
    6060      foreach (var transformer in arr)
     
    6464
    6565
    66     static Transformer() {
    67       Register<IntValue>(new ValueTypeValueTransformer<IntValue, int>());
    68       Register<DoubleValue>(new ValueTypeValueTransformer<DoubleValue, double>());
    69       Register<PercentValue>(new ValueTypeValueTransformer<PercentValue, double>());
    70       Register<BoolValue>(new ValueTypeValueTransformer<BoolValue, bool>());
    71       Register<DateTimeValue>(new ValueTypeValueTransformer<DateTimeValue, DateTime>());
    72       Register<StringValue>(new StringValueTransformer());
     66    static JsonItemConverter() {
     67      Register<IntValue>(new ValueTypeValueConverter<IntValue, int>());
     68      Register<DoubleValue>(new ValueTypeValueConverter<DoubleValue, double>());
     69      Register<PercentValue>(new ValueTypeValueConverter<PercentValue, double>());
     70      Register<BoolValue>(new ValueTypeValueConverter<BoolValue, bool>());
     71      Register<DateTimeValue>(new ValueTypeValueConverter<DateTimeValue, DateTime>());
     72      Register<StringValue>(new StringValueConverter());
    7373
    74       Register<IntArray>(new ValueTypeArrayTransformer<IntArray, int>());
    75       Register<DoubleArray>(new ValueTypeArrayTransformer<DoubleArray, double>());
    76       Register<PercentArray>(new ValueTypeArrayTransformer<PercentArray, double>());
    77       Register<BoolArray>(new ValueTypeArrayTransformer<BoolArray, bool>());
     74      Register<IntArray>(new ValueTypeArrayConverter<IntArray, int>());
     75      Register<DoubleArray>(new ValueTypeArrayConverter<DoubleArray, double>());
     76      Register<PercentArray>(new ValueTypeArrayConverter<PercentArray, double>());
     77      Register<BoolArray>(new ValueTypeArrayConverter<BoolArray, bool>());
    7878
    79       Register<IntMatrix>(new ValueTypeMatrixTransformer<IntMatrix, int>());
    80       Register<DoubleMatrix>(new ValueTypeMatrixTransformer<DoubleMatrix, double>());
    81       Register<PercentMatrix>(new ValueTypeMatrixTransformer<PercentMatrix, double>());
    82       Register<BoolMatrix>(new ValueTypeMatrixTransformer<BoolMatrix, bool>());
     79      Register<IntMatrix>(new ValueTypeMatrixConverter<IntMatrix, int>());
     80      Register<DoubleMatrix>(new ValueTypeMatrixConverter<DoubleMatrix, double>());
     81      Register<PercentMatrix>(new ValueTypeMatrixConverter<PercentMatrix, double>());
     82      Register<BoolMatrix>(new ValueTypeMatrixConverter<BoolMatrix, bool>());
    8383
    84       Register(typeof(IConstrainedValueParameter<>), new ConstrainedValueParameterTransformer());
    85       Register(typeof(ILookupParameter), new LookupParameterTransformer());
    86       Register(typeof(IValueParameter), new ValueParameterTransformer());
    87       Register(typeof(IParameterizedItem), new ParameterizedItemTransformer());
    88       Register(typeof(ICheckedMultiOperator<>), new MultiCheckedOperatorTransformer());
     84      Register(typeof(IConstrainedValueParameter<>), new ConstrainedValueParameterConverter());
     85      Register(typeof(ILookupParameter), new LookupParameterConverter());
     86      Register(typeof(IValueParameter), new ValueParameterConverter());
     87      Register(typeof(IParameterizedItem), new ParameterizedItemConverter());
     88      Register(typeof(ICheckedMultiOperator<>), new MultiCheckedOperatorConverter());
     89      Register(typeof(EnumValue<>), new EnumTypeConverter())
    8990    }
    9091
Note: See TracChangeset for help on using the changeset viewer.