- Timestamp:
- 04/29/19 15:00:56 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r16565 r16872 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Parameters { … … 40 40 } 41 41 } 42 42 43 43 [Storable] 44 44 private ItemSet<T> validValues; … … 52 52 get { return this.value; } 53 53 set { 54 if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter."); 54 55 if (value != this.value) { 55 56 if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value."); … … 74 75 } 75 76 77 [Storable(DefaultValue = false)] 78 private bool readOnly; 79 public bool ReadOnly { 80 get { return readOnly; } 81 set { 82 if (value == readOnly) return; 83 readOnly = value; 84 OnReadOnlyChanged(); 85 } 86 } 87 76 88 [Storable(DefaultValue = true)] 77 89 private bool getsCollected; … … 93 105 validValues = cloner.Clone(original.validValues); 94 106 value = cloner.Clone(original.value); 107 readOnly = original.readOnly; 95 108 getsCollected = original.getsCollected; 96 109 Initialize(); … … 99 112 : base("Anonymous", typeof(T)) { 100 113 this.validValues = new ItemSet<T>(); 114 this.readOnly = false; 101 115 this.getsCollected = true; 102 116 Initialize(); … … 105 119 : base(name, typeof(T)) { 106 120 this.validValues = new ItemSet<T>(); 121 this.readOnly = false; 107 122 this.getsCollected = true; 108 123 Initialize(); … … 111 126 : base(name, typeof(T)) { 112 127 this.validValues = new ItemSet<T>(); 128 this.readOnly = false; 113 129 this.getsCollected = getsCollected; 114 130 Initialize(); … … 117 133 : base(name, typeof(T)) { 118 134 this.validValues = validValues; 135 this.readOnly = false; 119 136 this.getsCollected = true; 120 137 Initialize(); … … 123 140 : base(name, typeof(T)) { 124 141 this.validValues = validValues; 142 this.readOnly = false; 125 143 this.getsCollected = getsCollected; 126 144 Initialize(); … … 130 148 this.validValues = validValues; 131 149 this.value = value; 150 this.readOnly = false; 132 151 this.getsCollected = true; 133 152 Initialize(); … … 137 156 this.validValues = validValues; 138 157 this.value = value; 158 this.readOnly = false; 139 159 this.getsCollected = getsCollected; 140 160 Initialize(); … … 143 163 : base(name, description, typeof(T)) { 144 164 this.validValues = new ItemSet<T>(); 165 this.readOnly = false; 145 166 this.getsCollected = true; 146 167 Initialize(); … … 149 170 : base(name, description, typeof(T)) { 150 171 this.validValues = new ItemSet<T>(); 172 this.readOnly = false; 151 173 this.getsCollected = getsCollected; 152 174 Initialize(); … … 155 177 : base(name, description, typeof(T)) { 156 178 this.validValues = validValues; 179 this.readOnly = false; 157 180 this.getsCollected = true; 158 181 Initialize(); … … 161 184 : base(name, description, typeof(T)) { 162 185 this.validValues = validValues; 186 this.readOnly = false; 163 187 this.getsCollected = getsCollected; 164 188 Initialize(); … … 168 192 this.validValues = validValues; 169 193 this.value = value; 194 this.readOnly = false; 170 195 this.getsCollected = true; 171 196 Initialize(); … … 175 200 this.validValues = validValues; 176 201 this.value = value; 202 this.readOnly = false; 177 203 this.getsCollected = getsCollected; 178 204 Initialize(); … … 212 238 OnToStringChanged(); 213 239 } 240 public event EventHandler ReadOnlyChanged; 241 protected virtual void OnReadOnlyChanged() { 242 EventHandler handler = ReadOnlyChanged; 243 if (handler != null) handler(this, EventArgs.Empty); 244 } 214 245 public event EventHandler GetsCollectedChanged; 215 246 protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset
for help on using the changeset viewer.