Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/14 12:47:42 (10 years ago)
Author:
rstoll
Message:

Changed row and columnIndex in order to be consistent with PreprocessingData

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs

    r10586 r10616  
    9191    }
    9292
    93     public string GetValue(int rowIndex, int columnIndex) {
     93    public string GetValue(int columnIndex, int rowIndex) {
    9494      return preprocessingData.GetCellAsString(columnIndex, rowIndex);
    9595    }
    9696
    97     public bool SetValue(string value, int rowIndex, int columnIndex) {
     97    public bool SetValue(string value, int columnIndex, int rowIndex) {
    9898      bool valid = false;
    9999      if (preprocessingData.IsType<double>(columnIndex)) {
    100100        double val;
    101101        valid = double.TryParse(value, out val);
    102         if (valid) {
    103           preprocessingData.SetCell<double>(columnIndex, rowIndex, val);
    104         }
     102        SetValueIfValid(columnIndex, rowIndex, valid, value);
    105103      } else if (preprocessingData.IsType<string>(columnIndex)) {
    106104        valid = value != null;
    107         if (valid) {
    108           preprocessingData.SetCell<string>(columnIndex, rowIndex, value);
    109         }
     105        SetValueIfValid(columnIndex, rowIndex, valid, value);
    110106      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
    111107        DateTime date;
    112108        valid = DateTime.TryParse(value, out date);
    113         if (valid) {
    114           preprocessingData.SetCell<DateTime>(columnIndex, rowIndex, date);
    115         }
     109        SetValueIfValid(columnIndex, rowIndex, valid, value);
    116110      } else {
    117111        throw new ArgumentException("column " + columnIndex + " contains a non supported type.");
    118112      }
     113      return valid;
     114    }
    119115
    120       return valid;
     116    private void SetValueIfValid<T>(int columnIndex, int rowIndex, bool valid, T value) {
     117      if (valid) {
     118        preprocessingData.SetCell<T>(columnIndex, rowIndex, value);
     119      }
    121120    }
    122121
Note: See TracChangeset for help on using the changeset viewer.