- Timestamp:
- 04/18/10 02:27:02 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Collections
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs
r3381 r3390 35 35 [StorableClass] 36 36 [Item("ItemList<T>", "Represents a list of items.")] 37 public class ItemList<T> : ObservableList<T>, IItem where T : class, IItem {37 public class ItemList<T> : ObservableList<T>, IItemList<T> where T : class, IItem { 38 38 public virtual string ItemName { 39 39 get { return ItemAttribute.GetName(this.GetType()); } … … 46 46 } 47 47 48 public ItemList() : base() { } 49 public ItemList(int capacity) : base(capacity) { } 50 public ItemList(IEnumerable<T> collection) : base(collection) { } 48 [Storable] 49 private List<T> Items { 50 get { return list; } 51 set { list = value; } 52 } 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemList() 68 : base() { 69 readOnlyView = ((ICollection<T>)list).IsReadOnly; 70 } 71 public ItemList(int capacity) 72 : base(capacity) { 73 readOnlyView = ((ICollection<T>)list).IsReadOnly; 74 } 75 public ItemList(IEnumerable<T> collection) 76 : base(collection) { 77 readOnlyView = ((ICollection<T>)list).IsReadOnly; 78 } 79 [StorableConstructor] 80 protected ItemList(bool deserializing) { } 51 81 52 82 public object Clone() { 53 83 return Clone(new Cloner()); 54 84 } 55 56 85 public virtual IDeepCloneable Clone(Cloner cloner) { 57 86 ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType()); 58 87 cloner.RegisterClonedObject(this, clone); 59 clone. ReadOnlyView = ReadOnlyView;88 clone.readOnlyView = readOnlyView; 60 89 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 61 90 return clone; 91 } 92 93 public new ReadOnlyItemList<T> AsReadOnly() { 94 return new ReadOnlyItemList<T>(this); 62 95 } 63 96 … … 76 109 if (handler != null) handler(this, EventArgs.Empty); 77 110 } 111 public event EventHandler ReadOnlyViewChanged; 112 protected virtual void OnReadOnlyViewChanged() { 113 EventHandler handler = ReadOnlyViewChanged; 114 if (handler != null) handler(this, EventArgs.Empty); 115 } 78 116 } 79 117 }
Note: See TracChangeset
for help on using the changeset viewer.