- 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/ItemArray.cs
r3381 r3390 35 35 [StorableClass] 36 36 [Item("ItemArray<T>", "Represents an array of items.")] 37 public class ItemArray<T> : ObservableArray<T>, IItem where T : class, IItem {37 public class ItemArray<T> : ObservableArray<T>, IItemArray<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 ItemArray() : base() { } 49 public ItemArray(int length) : base(length) { } 50 public ItemArray(T[] array) : base(array) { } 51 public ItemArray(IEnumerable<T> collection) : base(collection) { } 48 [Storable] 49 private T[] Items { 50 get { return array; } 51 set { array = value; } 52 } 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !(array.IsReadOnly)) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemArray() 68 : base() { 69 readOnlyView = array.IsReadOnly; 70 } 71 public ItemArray(int length) 72 : base(length) { 73 readOnlyView = array.IsReadOnly; 74 } 75 public ItemArray(T[] array) 76 : base(array) { 77 readOnlyView = array.IsReadOnly; 78 } 79 public ItemArray(IEnumerable<T> collection) 80 : base(collection) { 81 readOnlyView = array.IsReadOnly; 82 } 83 [StorableConstructor] 84 protected ItemArray(bool deserializing) { } 52 85 53 86 public object Clone() { 54 87 return Clone(new Cloner()); 55 88 } 56 57 89 public virtual IDeepCloneable Clone(Cloner cloner) { 58 90 ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType()); 59 91 cloner.RegisterClonedObject(this, clone); 60 clone. ReadOnlyView = ReadOnlyView;92 clone.readOnlyView = readOnlyView; 61 93 clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray(); 62 94 return clone; 95 } 96 97 public new ReadOnlyItemArray<T> AsReadOnly() { 98 return new ReadOnlyItemArray<T>(this); 63 99 } 64 100 … … 77 113 if (handler != null) handler(this, EventArgs.Empty); 78 114 } 115 public event EventHandler ReadOnlyViewChanged; 116 protected virtual void OnReadOnlyViewChanged() { 117 EventHandler handler = ReadOnlyViewChanged; 118 if (handler != null) handler(this, EventArgs.Empty); 119 } 79 120 } 80 121 }
Note: See TracChangeset
for help on using the changeset viewer.