Changeset 13597
- Timestamp:
- 02/08/16 14:24:18 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Collections/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Collections/3.3/ObservableCollection.cs
r12012 r13597 20 20 #endregion 21 21 22 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 22 23 using System; 23 24 using System.Collections; 24 25 using System.Collections.Generic; 25 26 using System.ComponentModel; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;27 using System.Linq; 27 28 28 29 namespace HeuristicLab.Collections { … … 96 97 public void AddRange(IEnumerable<T> collection) { 97 98 int capacity = list.Capacity; 98 int count = list.Count;99 list.AddRange( collection);100 if ( list.Count != count) {99 ICollection<T> items = collection as ICollection<T> ?? collection.ToList(); 100 list.AddRange(items); 101 if (items.Count > 0) { 101 102 if (list.Capacity != capacity) 102 103 OnPropertyChanged("Capacity"); 103 104 OnPropertyChanged("Count"); 104 OnItemsAdded( collection);105 OnItemsAdded(items); 105 106 } 106 107 } -
trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs
r12012 r13597 20 20 #endregion 21 21 22 using HeuristicLab.Common; 23 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 22 24 using System; 23 25 using System.Collections; … … 25 27 using System.ComponentModel; 26 28 using System.Linq; 27 using HeuristicLab.Common;28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;29 29 30 30 namespace HeuristicLab.Collections { … … 169 169 int capacity = list.Capacity; 170 170 int index = list.Count; 171 list.AddRange(collection);172 171 List<IndexedItem<T>> items = new List<IndexedItem<T>>(); 173 172 foreach (T item in collection) { … … 175 174 index++; 176 175 } 176 list.AddRange(items.Select(x => x.Value)); 177 177 if (items.Count > 0) { 178 178 OnItemsAdded(items); 179 OnItemsAdded( collection);179 OnItemsAdded(items.Select(x => x.Value)); 180 180 if (list.Capacity != capacity) 181 181 OnPropertyChanged("Capacity");
Note: See TracChangeset
for help on using the changeset viewer.