Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/20 17:17:37 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
  • updated view models for new json item structure
  • updated SingleLineArrayJsonWriter
File:
1 edited

Legend:

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

    r17471 r17473  
    1111  /// Main data class for json interface.
    1212  /// </summary>
    13   public class JsonItem : IJsonItem {
     13  public abstract class JsonItem : IJsonItem {
    1414
    1515    public class JsonItemValidator : IJsonItemValidator {
     
    2525      }
    2626
     27      // TODO: return ValidationResult ?
    2728      private bool ValidateHelper(JsonItem item, ref IList<IJsonItem> faultyItems) {
    2829        int hash = item.GetHashCode();
     
    3031          return r;
    3132
    32         bool res = true;
    33         if (item.Value != null && item.Range != null)
    34           res = item.IsInRange();
     33        bool res = item.Validate();
    3534        if (!res) faultyItems.Add(item);
    3635        Cache.Add(hash, res);
    37         if(item.Children != null)
     36        if(item.Children != null) {
    3837          foreach (var child in item.Children)
    39             res = res && ValidateHelper(child as JsonItem, ref faultyItems);
     38            if (!ValidateHelper(child as JsonItem, ref faultyItems))
     39              res = false && res;
     40        }
    4041        return res;
    4142      }
     
    6263    }
    6364
    64     public virtual object Value { get; set; }
     65    //public virtual object Value { get; set; }
    6566
    66     public virtual IEnumerable<object> Range { get; set; }
     67    //public virtual IEnumerable<object> Range { get; set; }
    6768   
    6869    // TODO jsonIgnore dataType?
     
    105106
    106107    public virtual void SetFromJObject(JObject jObject) {
    107       Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>();
    108       Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>();
     108      //Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>();
     109      //Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>();
    109110    }
    110111    #endregion
     
    114115     * TODO protected abstract bool Validate();
    115116     */
    116      
     117    protected abstract bool Validate();
     118    /*
    117119    protected virtual bool IsInRange() {
    118120      bool b1 = true, b2 = true;
     
    156158        (((T)max).CompareTo(value) == 1 || ((T)max).CompareTo(value) == 0);
    157159    }
     160    */
    158161    #endregion
    159162  }
Note: See TracChangeset for help on using the changeset viewer.