Free cookie consent management tool by TermsFeed Policy Generator

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

    r17342 r17394  
    99namespace HeuristicLab.JsonInterface {
    1010  public class EnumTypeConverter : BaseConverter {
    11     public override void InjectData(IItem item, JsonItem data) =>
    12       item.Cast<dynamic>().Value = Enum.Parse(
     11    public override int Priority => 1;
     12    public override Type ConvertableType => typeof(EnumValue<>);
     13
     14    public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) =>
     15      ((dynamic)item).Value = Enum.Parse(
    1316        item.GetType().GenericTypeArguments.First(),
    1417        CastValue<string>(data.Value));
    1518
    16     public override JsonItem ExtractData(IItem value) {
    17       JsonItem data = new JsonItem();
     19    public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) {
    1820      object val = ((dynamic)value).Value;
    1921      Type enumType = val.GetType();
    20       data.Value = Enum.GetName(enumType, val);
    21       data.Range = Enum.GetNames(enumType);
    22       return data;
     22      item.Value = Enum.GetName(enumType, val);
     23      item.Range = Enum.GetNames(enumType);
    2324    }
    2425  }
Note: See TracChangeset for help on using the changeset viewer.