- Timestamp:
- 04/18/10 02:27:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Collections/3.3/ObservableCollection.cs
r3370 r3390 24 24 using System.Collections.Generic; 25 25 using System.ComponentModel; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;27 26 28 27 namespace HeuristicLab.Collections { 29 28 [Serializable] 30 [StorableClass]31 29 public class ObservableCollection<T> : IObservableCollection<T> { 32 [Storable]33 30 protected List<T> list; 34 31 35 32 #region Properties 36 [Storable]37 private bool readOnlyView;38 public virtual bool ReadOnlyView {39 get { return readOnlyView; }40 set {41 if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) {42 readOnlyView = value;43 OnReadOnlyViewChanged();44 OnPropertyChanged("ReadOnlyView");45 }46 }47 }48 49 33 public int Capacity { 50 34 get { return list.Capacity; } … … 67 51 public ObservableCollection() { 68 52 list = new List<T>(); 69 readOnlyView = ((ICollection<T>)list).IsReadOnly;70 53 } 71 54 public ObservableCollection(int capacity) { 72 55 list = new List<T>(capacity); 73 readOnlyView = ((ICollection<T>)list).IsReadOnly;74 56 } 75 57 public ObservableCollection(IEnumerable<T> collection) { 76 58 list = new List<T>(collection); 77 readOnlyView = ((ICollection<T>)list).IsReadOnly;78 59 } 79 60 #endregion … … 205 186 #region Events 206 187 [field: NonSerialized] 207 public event EventHandler ReadOnlyViewChanged;208 protected virtual void OnReadOnlyViewChanged() {209 EventHandler handler = ReadOnlyViewChanged;210 if (handler != null) handler(this, EventArgs.Empty);211 }212 213 [field: NonSerialized]214 188 public event CollectionItemsChangedEventHandler<T> ItemsAdded; 215 189 protected virtual void OnItemsAdded(IEnumerable<T> items) {
Note: See TracChangeset
for help on using the changeset viewer.