Changeset 17614 for branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
- Timestamp:
- 06/19/20 17:53:36 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r17226 r17614 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HEAL.Attic; … … 57 58 } 58 59 60 public override void Repopulate(IEnumerable<IItem> items) { 61 var itemsOfT = items.OfType<T>().ToList(); 62 T oldItem = Value; 63 ValidValues.Clear(); 64 T defaultItem = itemsOfT.FirstOrDefault(); 65 66 foreach (T i in itemsOfT.OrderBy(x => x is INamedItem ? ((INamedItem)x).Name : x.ItemName)) 67 ValidValues.Add(i); 68 69 if (oldItem != null) { 70 T item = ValidValues.FirstOrDefault(x => x.GetType() == oldItem.GetType()); 71 if (item != null) Value = item; 72 else oldItem = null; 73 } 74 if (oldItem == null && defaultItem != null) 75 Value = defaultItem; 76 } 77 59 78 protected override void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 60 79 if (Value == null) Value = ValidValues.First();
Note: See TracChangeset
for help on using the changeset viewer.