Changeset 10616 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs
- Timestamp:
- 03/19/14 12:47:42 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs
r10586 r10616 91 91 } 92 92 93 public string GetValue(int rowIndex, int columnIndex) {93 public string GetValue(int columnIndex, int rowIndex) { 94 94 return preprocessingData.GetCellAsString(columnIndex, rowIndex); 95 95 } 96 96 97 public bool SetValue(string value, int rowIndex, int columnIndex) {97 public bool SetValue(string value, int columnIndex, int rowIndex) { 98 98 bool valid = false; 99 99 if (preprocessingData.IsType<double>(columnIndex)) { 100 100 double val; 101 101 valid = double.TryParse(value, out val); 102 if (valid) { 103 preprocessingData.SetCell<double>(columnIndex, rowIndex, val); 104 } 102 SetValueIfValid(columnIndex, rowIndex, valid, value); 105 103 } else if (preprocessingData.IsType<string>(columnIndex)) { 106 104 valid = value != null; 107 if (valid) { 108 preprocessingData.SetCell<string>(columnIndex, rowIndex, value); 109 } 105 SetValueIfValid(columnIndex, rowIndex, valid, value); 110 106 } else if (preprocessingData.IsType<DateTime>(columnIndex)) { 111 107 DateTime date; 112 108 valid = DateTime.TryParse(value, out date); 113 if (valid) { 114 preprocessingData.SetCell<DateTime>(columnIndex, rowIndex, date); 115 } 109 SetValueIfValid(columnIndex, rowIndex, valid, value); 116 110 } else { 117 111 throw new ArgumentException("column " + columnIndex + " contains a non supported type."); 118 112 } 113 return valid; 114 } 119 115 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 } 121 120 } 122 121
Note: See TracChangeset
for help on using the changeset viewer.