Changeset 12508


Ignore:
Timestamp:
06/25/15 13:07:51 (4 years ago)
Author:
mkommend
Message:

#2276: Minor changes in modifiable dataset.

Location:
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r12489 r12508  
    118118    }
    119119
     120    protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { }
     121
    120122    #region Backwards compatible code, remove with 3.5
    121123    private double[,] storableData;
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs

    r12489 r12508  
    4040    public override IDeepCloneable Clone(Cloner cloner) { return new ModifiableDataset(this, cloner); }
    4141    public ModifiableDataset() : base() { }
     42
     43    public ModifiableDataset(Dataset dataset) : base(dataset) { }
    4244    public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) : base(variableNames, variableValues) { }
    4345
     
    5658        variableValues[variableNames[i]][row] = list[i];
    5759      }
    58       OnRowsChanged();
    5960      OnReset();
    6061    }
     
    123124
    124125      list[row] = value;
     126      OnItemChanged(row, variableNames.IndexOf(variableName));
    125127    }
    126128
     
    153155
    154156    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    155       return ValidateValue(value, out errorMessage);
    156     }
    157 
    158     private static bool ValidateValue(string value, out string errorMessage) {
    159       double dv;
    160       if (double.TryParse(value, out dv)) {
    161         errorMessage = string.Empty;
    162         return true;
    163       }
    164       DateTime dt;
    165       if (DateTime.TryParse(value, out dt)) {
    166         errorMessage = string.Empty;
    167         return true;
    168       }
    169       errorMessage = "Value could not be validated. Please ensure that the value is either a string, a double, or a DateTime value.";
    170       return false;
     157      errorMessage = string.Empty;
     158      return true;
    171159    }
    172160
     
    174162    public override event EventHandler RowsChanged;
    175163    private void OnRowsChanged() {
    176       var changed = RowsChanged;
    177       if (changed != null)
    178         changed(this, EventArgs.Empty);
     164      var handler = RowsChanged;
     165      if (handler != null)
     166        handler(this, EventArgs.Empty);
    179167    }
    180168
    181169    public override event EventHandler ColumnsChanged;
    182170    private void OnColumnsChanged() {
    183       var changed = ColumnsChanged;
    184       if (changed != null)
    185         changed(this, EventArgs.Empty);
    186     }
    187 
    188     public override event EventHandler RowNamesChanged;
    189     private void OnRowNamesChanged() {
    190       var changed = RowNamesChanged;
    191       if (changed != null)
    192         changed(this, EventArgs.Empty);
     171      var handler = ColumnsChanged;
     172      if (handler != null)
     173        handler(this, EventArgs.Empty);
    193174    }
    194175
    195176    public override event EventHandler ColumnNamesChanged;
    196177    private void OnColumnNamesChanged() {
    197       var changed = ColumnNamesChanged;
    198       if (changed != null)
    199         changed(this, EventArgs.Empty);
     178      var handler = ColumnNamesChanged;
     179      if (handler != null)
     180        handler(this, EventArgs.Empty);
    200181    }
    201182
    202183    public override event EventHandler Reset;
    203184    private void OnReset() {
    204       var reset = Reset;
    205       if (reset != null)
    206         reset(this, EventArgs.Empty);
     185      var handler = Reset;
     186      if (handler != null)
     187        handler(this, EventArgs.Empty);
    207188    }
    208189
    209     // not sure if this is really applicable in the ModifiableDataset
    210     // since this is not a matrix and values are changed based on row + variableName
    211190    public override event EventHandler<EventArgs<int, int>> ItemChanged;
    212191    private void OnItemChanged(int rowIndex, int columnIndex) {
    213       var changed = ItemChanged;
    214       if (changed != null) {
    215         changed(this, new EventArgs<int, int>(rowIndex, columnIndex));
     192      var handler = ItemChanged;
     193      if (handler != null) {
     194        handler(this, new EventArgs<int, int>(rowIndex, columnIndex));
    216195      }
    217196    }
Note: See TracChangeset for help on using the changeset viewer.