Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16282


Ignore:
Timestamp:
11/07/18 14:01:20 (6 years ago)
Author:
abeham
Message:

#2916: merged to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Analysis

  • stable/HeuristicLab.Analysis/3.3/DataVisualization/IndexedDataRow.cs

    r15584 r16282  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.ComponentModel;
     25using System.Linq;
    2226using HeuristicLab.Collections;
    2327using HeuristicLab.Common;
    2428using HeuristicLab.Core;
    2529using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using System;
    27 using System.Collections.Generic;
    28 using System.ComponentModel;
    29 using System.Linq;
    3030
    3131namespace HeuristicLab.Analysis {
     
    5858      set { visualProperties = value; }
    5959    }
    60     [Storable(Name = "values")]
     60    // BackwardsCompatibility3.3
     61    #region Backwards compatible code, remove with 3.4
     62    // tuples are stored inefficiently
     63    [Storable(Name = "values", AllowOneWay = true)]
    6164    private IEnumerable<Tuple<T, double>> StorableValues {
    62       get { return values; }
    6365      set { values = new ObservableList<Tuple<T, double>>(value); }
     66    }
     67    #endregion
     68    private T[] storableX;
     69    [Storable(Name = "x")]
     70    private T[] StorableX {
     71      get { return Values.Select(x => x.Item1).ToArray(); }
     72      set { storableX = value; }
     73    }
     74    private double[] storableY;
     75    [Storable(Name = "y")]
     76    private double[] StorableY {
     77      get { return Values.Select(x => x.Item2).ToArray(); }
     78      set { storableY = value; }
    6479    }
    6580    #endregion
     
    109124      VisualProperties.DisplayName = Name;
    110125    }
     126
     127    [StorableHook(HookType.AfterDeserialization)]
     128    private void AfterDeserialization() {
     129      if (storableX != null && storableY != null) {
     130        values = new ObservableList<Tuple<T, double>>(storableX.Zip(storableY, (x, y) => Tuple.Create(x, y)));
     131        storableX = null;
     132        storableY = null;
     133      } else if (values == null) throw new InvalidOperationException("Deserialization problem with IndexedDataRow.");
     134    }
    111135  }
    112136}
Note: See TracChangeset for help on using the changeset viewer.