Ignore:
Timestamp:
01/27/20 10:33:01 (15 months ago)
Author:
dpiringe
Message:

#3026

  • added interfaces IJsonItem and IJsonItemValidator
  • replaced every reference JsonItem with IJsonItem
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs

    r17394 r17406  
    2020      = new Dictionary<Type, IJsonItemConverter>();
    2121
    22     private IDictionary<int, JsonItem> Cache { get; set; }
    23       = new Dictionary<int, JsonItem>();
     22    private IDictionary<int, IJsonItem> Cache { get; set; }
     23      = new Dictionary<int, IJsonItem>();
    2424
    2525    public int Priority => throw new NotImplementedException();
     
    5151    }
    5252   
    53     public void Inject(IItem item, JsonItem data, IJsonItemConverter root) {
     53    public void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    5454      if(!Cache.ContainsKey(item.GetHashCode())) {
    5555        IJsonItemConverter converter = GetConverter(item.GetType());
     
    5858    }
    5959
    60     public JsonItem Extract(IItem item, IJsonItemConverter root) {
     60    public IJsonItem Extract(IItem item, IJsonItemConverter root) {
    6161      int hash = item.GetHashCode();
    62       if (Cache.TryGetValue(hash, out JsonItem val))
     62      if (Cache.TryGetValue(hash, out IJsonItem val))
    6363        return val;
    6464      else {
    6565        IJsonItemConverter converter = GetConverter(item.GetType());
    6666        if (converter == null) return new UnsupportedJsonItem();
    67         JsonItem tmp = GetConverter(item.GetType()).Extract(item, root);
     67        IJsonItem tmp = GetConverter(item.GetType()).Extract(item, root);
    6868        Cache.Add(hash, tmp);
    6969        return tmp;
     
    7171    }
    7272   
    73     public static void Inject(IItem item, JsonItem data) {
     73    public static void Inject(IItem item, IJsonItem data) {
    7474      IJsonItemConverter c = JsonItemConverterFactory.Create();
    7575      c.Inject(item, data, c);
    7676    }
    7777
    78     public static JsonItem Extract(IItem item) {
     78    public static IJsonItem Extract(IItem item) {
    7979      IJsonItemConverter c = JsonItemConverterFactory.Create();
    8080      return c.Extract(item, c);
Note: See TracChangeset for help on using the changeset viewer.