Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/19 16:23:42 (3 years ago)
Author:
dpiringe
Message:

#3026:

  • changed the namespace from ParameterTest to HeuristicLab.Manufacture
  • added an extension method for Type to get the distance of an interface based on the target type
  • renamed methods ToData, SetValue to Extract, Inject
  • new implementation of the template generation with transformers (not the final name)
  • started to use the new transformers for the instantiation of IOptimizer-objects (out of a template)
  • new transformers: LookupParameterTransformer and DummyTransformer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/EnumTypeTransformer.cs

    r17263 r17266  
    77using HeuristicLab.Data;
    88
    9 namespace ParameterTest {
     9namespace HeuristicLab.Manufacture {
    1010  public class EnumTypeTransformer : BaseTransformer {
    11     public override IItem FromData(ParameterData obj, Type targetType) {
    12       Type enumType = targetType.GenericTypeArguments.First();
    13       var data = Enum.Parse(enumType, CastValue<string>(obj.Default));
    14       //item.Cast<dynamic>().Value = data;
    15       return Instantiate(targetType, data);
    16     }
    1711
    18     public override void SetValue(IItem item, ParameterData data) {
    19       Type enumType = item.GetType().GenericTypeArguments.First();
    20       item.Cast<dynamic>().Value = Enum.Parse(enumType, CastValue<string>(data.Default));
    21     }
     12    public override void InjectData(IItem item, ParameterData data) =>
     13      item.Cast<dynamic>().Value = Enum.Parse(
     14        item.GetType().GenericTypeArguments.First(),
     15        CastValue<string>(data.Default));
    2216
    23     public override ParameterData ToData(IItem value) {
    24       ParameterData data = base.ToData(value);
     17    public override ParameterData ExtractData(IItem value) {
     18      ParameterData data = new ParameterData();
    2519      object val = ((dynamic)value).Value;
    2620      Type enumType = val.GetType();
Note: See TracChangeset for help on using the changeset viewer.