Changeset 8535 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations
- Timestamp:
- 08/29/12 09:22:21 (12 years ago)
- Location:
- branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/ParameterConfiguration.cs
r8517 r8535 57 57 } 58 58 OnOptimizeChanged(); 59 OnCombinationsCountChanged(); 59 60 OnToStringChanged(); 61 } 62 } 63 } 64 65 [Storable] 66 protected long combinationsCount; 67 public virtual long CombinationsCount { 68 get { return combinationsCount; } 69 set { 70 if (combinationsCount != value) { 71 combinationsCount = value; 72 OnCombinationsCountChanged(); 60 73 } 61 74 } … … 179 192 180 193 #region Constructors and Cloning 181 public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues) { 194 public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues) 195 : base() { 182 196 this.AutoPopulateValueConfigurations = true; 183 197 this.ParameterName = parameterName; … … 202 216 } 203 217 } 204 public ParameterConfiguration(string parameterName, Type type, IItem actualValue, IEnumerable<IValueConfiguration> valueConfigurations) { 218 public ParameterConfiguration(string parameterName, Type type, IItem actualValue, IEnumerable<IValueConfiguration> valueConfigurations) 219 : base() { 205 220 this.AutoPopulateValueConfigurations = false; 206 221 this.ParameterName = parameterName; … … 211 226 this.validTypes = new Type[] { type }; 212 227 this.IsNullable = false; 213 this.itemImage = valueConfigurations. Count() > 0 ? valueConfigurations.FirstOrDefault().ItemImage : null;228 this.itemImage = valueConfigurations.Any() ? valueConfigurations.First().ItemImage : null; 214 229 this.ValueConfigurations = new CheckedValueConfigurationList(valueConfigurations); 215 230 this.ActualValue = new ConstrainedValue(actualValue, type, CreateValidValues(), this.IsNullable); 216 231 } 217 public ParameterConfiguration(string parameterName, Type type, IItem actualValue) { 232 public ParameterConfiguration(string parameterName, Type type, IItem actualValue) 233 : base() { 218 234 this.AutoPopulateValueConfigurations = true; 219 235 this.ParameterName = parameterName; … … 231 247 } 232 248 } 233 protected ParameterConfiguration() { }249 protected ParameterConfiguration() : base() { } 234 250 [StorableConstructor] 235 251 protected ParameterConfiguration(bool deserializing) { } 236 237 252 protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner) 238 253 : base(original, cloner) { … … 316 331 } 317 332 } 333 valueConfiguration.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged(); 318 334 this.ValueConfigurations.Add(valueConfiguration, true); 319 335 } … … 357 373 return new List<Type> { parameter }; 358 374 359 // TODO: not sure if this ifmakes sense; maybe only leave else branch here375 // TODO: check if this makes sense; maybe only leave else branch here 360 376 if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) { 361 377 // use existing validvalues if known … … 391 407 392 408 // copy value from ValidValues; this ensures that previously set ActualNames for a type are kept 393 IItem value = this.validValues. Where(v => v.GetType() == type).SingleOrDefault();409 IItem value = this.validValues.SingleOrDefault(v => v.GetType() == type); 394 410 if (value != null) 395 411 return value; … … 425 441 private void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 426 442 OnToStringChanged(); 443 OnCombinationsCountChanged(); 427 444 KeepActualValueConfigurationIndexConsistent(); 428 445 } … … 430 447 private void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 431 448 OnToStringChanged(); 449 OnCombinationsCountChanged(); 432 450 KeepActualValueConfigurationIndexConsistent(); 433 451 } 434 452 private void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 435 453 OnToStringChanged(); 454 OnCombinationsCountChanged(); 436 455 KeepActualValueConfigurationIndexConsistent(); 437 456 } … … 451 470 public virtual bool CanChangeName { 452 471 get { return false; } 453 }454 public override string ItemDescription {455 get { return base.ItemDescription; }456 }457 public override string ItemName {458 get { return base.ItemName; }459 472 } 460 473 #endregion … … 494 507 protected virtual void OnOptimizeChanged() { 495 508 var handler = OptimizeChanged; 509 if (handler != null) handler(this, EventArgs.Empty); 510 } 511 512 public event EventHandler CombinationsCountChanged; 513 protected void OnCombinationsCountChanged() { 514 var handler = CombinationsCountChanged; 496 515 if (handler != null) handler(this, EventArgs.Empty); 497 516 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/SingleValuedParameterConfiguration.cs
r8517 r8535 29 29 [StorableClass] 30 30 public class SingleValuedParameterConfiguration : ParameterConfiguration { 31 32 31 #region Constructors and Cloning 33 32 [StorableConstructor] 34 33 protected SingleValuedParameterConfiguration(bool deserializing) : base(deserializing) { } 34 protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner) : base(original, cloner) { } 35 35 public SingleValuedParameterConfiguration(string parameterName, IValueParameter valueParameter) 36 36 : base(parameterName, valueParameter, false) { … … 57 57 this.validValues, 58 58 this.IsNullable); 59 }60 protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner)61 : base(original, cloner) {62 59 } 63 60 public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset
for help on using the changeset viewer.