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/JCGenerator.cs

    r17379 r17394  
    3535      // which have parameters aswell
    3636      AddInstantiableIItem(Constants.Algorithm, algorithm, genData);
    37       //IsConvertable(algorithm, true);
    3837      if (algorithm.Problem != null) // only when an problem exists
    3938        AddInstantiableIItem(Constants.Problem, algorithm.Problem, genData);
     
    4241      genData.Template[Constants.Parameters] = genData.JsonItems;
    4342      // serialize template and return string
    44       return CustomJsonWriter.Serialize(genData.Template);
     43      return SingleLineArrayJsonWriter.Serialize(genData.Template);
    4544    }
    4645   
    4746    #region Helper
    48     private static bool IsConvertable(object obj, bool throwException = false) {
    49       bool tmp = ConvertableAttribute.IsConvertable(obj);
    50       if (throwException && tmp)
    51         throw new NotSupportedException($"Type {obj.GetType().GetPrettyName(false)} is not convertable!");
    52       return tmp;
    53     }
    5447
    5548    private static void AddInstantiableIItem(string metaDataTagName, IItem item, GenData genData) {
    5649      JsonItem jsonItem = JsonItemConverter.Extract(item);
     50     
    5751      genData.Template[Constants.Metadata][metaDataTagName] = item.ItemName;
    5852      PopulateJsonItems(jsonItem, genData);
     
    6256    private static void PopulateJsonItems(JsonItem item, GenData genData) {
    6357      IEnumerable<JsonItem> tmpParameter = item.Children;
    64       item.Children = null;
    6558
    6659      if (item.Value != null || item.Range != null) {
Note: See TracChangeset for help on using the changeset viewer.