Changeset 8535 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/Range.cs
- Timestamp:
- 08/29/12 09:22:21 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/Range.cs
r8517 r8535 38 38 if (lowerBound != value) { 39 39 if (lowerBound != null) { 40 lowerBound.ValueChanged -= new EventHandler(lowerBound_ValueChanged); 40 41 lowerBound.ValueChanged -= new EventHandler(lowerBound_ToStringChanged); 41 42 } 42 43 lowerBound = value; 43 44 if (lowerBound != null) { 45 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 44 46 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 45 47 } … … 56 58 if (upperBound != value) { 57 59 if (upperBound != null) { 60 upperBound.ValueChanged -= new EventHandler(upperBound_ValueChanged); 58 61 upperBound.ValueChanged -= new EventHandler(upperBound_ToStringChanged); 59 62 } 60 63 upperBound = value; 61 64 if (upperBound != null) { 65 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 62 66 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 63 67 } … … 74 78 if (stepSize != value) { 75 79 if (stepSize != null) { 80 stepSize.ValueChanged -= new EventHandler(stepSize_ValueChanged); 76 81 stepSize.ValueChanged -= new EventHandler(stepSize_ToStringChanged); 77 82 } 78 83 stepSize = value; 79 84 if (stepSize != null) { 85 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 80 86 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 81 87 } … … 101 107 102 108 #region Constructors and Cloning 103 public Range(T lowerBound, T upperBound, T stepSize) {104 this.LowerBound = lowerBound;105 this.UpperBound = upperBound;106 this.StepSize = stepSize;107 }108 109 109 [StorableConstructor] 110 110 protected Range(bool deserializing) : base(deserializing) { } … … 115 115 this.StepSize = cloner.Clone(original.StepSize); 116 116 } 117 117 public Range(T lowerBound, T upperBound, T stepSize) 118 : base() { 119 this.LowerBound = lowerBound; 120 this.UpperBound = upperBound; 121 this.StepSize = stepSize; 122 } 118 123 [StorableHook(HookType.AfterDeserialization)] 119 124 private void AfterDeserialization() { 120 125 if (lowerBound != null) { 126 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 121 127 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 122 128 } 123 129 if (upperBound != null) { 130 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 124 131 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 125 132 } 126 133 if (stepSize != null) { 134 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 127 135 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 128 136 } … … 131 139 132 140 #region Events 141 private void lowerBound_ValueChanged(object sender, EventArgs e) { 142 OnLowerBoundChanged(); 143 } 144 private void upperBound_ValueChanged(object sender, EventArgs e) { 145 OnUpperBoundChanged(); 146 } 147 private void stepSize_ValueChanged(object sender, EventArgs e) { 148 OnStepSizeChanged(); 149 } 133 150 private void lowerBound_ToStringChanged(object sender, EventArgs e) { 134 151 OnToStringChanged(); … … 189 206 } 190 207 public bool Validate(string value, out string errorMessage) { 191 // TODO: check that upper is larger than lower and that stepsize < upper-lower208 // TODO: check that stepsize < upper - lower 192 209 T lower = (T)lowerBound.Clone(); 193 210 T upper = (T)upperBound.Clone(); … … 206 223 upperBound.SetValue(parts2[1]) && 207 224 stepSize.SetValue(parts1[1])) { 225 if (Comparer<T>.Default.Compare(lowerBound, upperBound) >= 0) { 226 errorMessage = "Invalid bounds. (Lower >= Upper)"; return false; 227 } 208 228 errorMessage = string.Empty; return true; 209 229 } else {
Note: See TracChangeset
for help on using the changeset viewer.