Changeset 3431 for trunk/sources/HeuristicLab.Core/3.3/Collections
- Timestamp:
- 04/20/10 03:00:00 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Collections
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemArray.cs
r3390 r3431 52 52 } 53 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 } 54 public ItemArray() : base() { } 55 public ItemArray(int length) : base(length) { } 56 public ItemArray(T[] array) : base(array) { } 57 public ItemArray(IEnumerable<T> collection) : base(collection) { } 83 58 [StorableConstructor] 84 59 protected ItemArray(bool deserializing) { } … … 90 65 ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType()); 91 66 cloner.RegisterClonedObject(this, clone); 92 clone.readOnlyView = readOnlyView;93 67 clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray(); 94 68 return clone; … … 113 87 if (handler != null) handler(this, EventArgs.Empty); 114 88 } 115 public event EventHandler ReadOnlyViewChanged;116 protected virtual void OnReadOnlyViewChanged() {117 EventHandler handler = ReadOnlyViewChanged;118 if (handler != null) handler(this, EventArgs.Empty);119 }120 89 } 121 90 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemCollection.cs
r3390 r3431 49 49 } 50 50 51 [Storable] 52 private bool readOnlyView; 53 public virtual bool ReadOnlyView { 54 get { return readOnlyView; } 55 set { 56 if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) { 57 readOnlyView = value; 58 OnReadOnlyViewChanged(); 59 OnPropertyChanged("ReadOnlyView"); 60 } 61 } 62 } 63 64 public ItemCollection() 65 : base() { 66 readOnlyView = ((ICollection<T>)list).IsReadOnly; 67 } 68 public ItemCollection(int capacity) 69 : base(capacity) { 70 readOnlyView = ((ICollection<T>)list).IsReadOnly; 71 } 72 public ItemCollection(IEnumerable<T> collection) 73 : base(collection) { 74 readOnlyView = ((ICollection<T>)list).IsReadOnly; 75 } 51 public ItemCollection() : base() { } 52 public ItemCollection(int capacity) : base(capacity) { } 53 public ItemCollection(IEnumerable<T> collection) : base(collection) { } 76 54 [StorableConstructor] 77 55 protected ItemCollection(bool deserializing) { } … … 83 61 ItemCollection<T> clone = (ItemCollection<T>)Activator.CreateInstance(this.GetType()); 84 62 cloner.RegisterClonedObject(this, clone); 85 clone.readOnlyView = readOnlyView;86 63 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 87 64 return clone; … … 106 83 if (handler != null) handler(this, EventArgs.Empty); 107 84 } 108 public event EventHandler ReadOnlyViewChanged;109 protected virtual void OnReadOnlyViewChanged() {110 EventHandler handler = ReadOnlyViewChanged;111 if (handler != null) handler(this, EventArgs.Empty);112 }113 85 } 114 86 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemDictionary.cs
r3390 r3431 49 49 } 50 50 51 [Storable] 52 private bool readOnlyView; 53 public virtual bool ReadOnlyView { 54 get { return readOnlyView; } 55 set { 56 if ((readOnlyView != value) && !((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly) { 57 readOnlyView = value; 58 OnReadOnlyViewChanged(); 59 OnPropertyChanged("ReadOnlyView"); 60 } 61 } 62 } 63 64 public ItemDictionary() 65 : base() { 66 readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly; 67 } 68 public ItemDictionary(int capacity) 69 : base(capacity) { 70 readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly; 71 } 72 public ItemDictionary(IDictionary<TKey, TValue> dictionary) 73 : base(dictionary) { 74 readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly; 75 } 51 public ItemDictionary() : base() { } 52 public ItemDictionary(int capacity) : base(capacity) { } 53 public ItemDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary) { } 76 54 [StorableConstructor] 77 55 protected ItemDictionary(bool deserializing) { } … … 83 61 ItemDictionary<TKey, TValue> clone = (ItemDictionary<TKey, TValue>)Activator.CreateInstance(this.GetType()); 84 62 cloner.RegisterClonedObject(this, clone); 85 clone.readOnlyView = readOnlyView;86 63 foreach (TKey key in dict.Keys) 87 64 clone.dict.Add((TKey)cloner.Clone(key), (TValue)cloner.Clone(dict[key])); … … 107 84 if (handler != null) handler(this, EventArgs.Empty); 108 85 } 109 public event EventHandler ReadOnlyViewChanged;110 protected virtual void OnReadOnlyViewChanged() {111 EventHandler handler = ReadOnlyViewChanged;112 if (handler != null) handler(this, EventArgs.Empty);113 }114 86 } 115 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs
r3390 r3431 52 52 } 53 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 } 54 public ItemList() : base() { } 55 public ItemList(int capacity) : base(capacity) { } 56 public ItemList(IEnumerable<T> collection) : base(collection) { } 79 57 [StorableConstructor] 80 58 protected ItemList(bool deserializing) { } … … 86 64 ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType()); 87 65 cloner.RegisterClonedObject(this, clone); 88 clone.readOnlyView = readOnlyView;89 66 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 90 67 return clone; … … 109 86 if (handler != null) handler(this, EventArgs.Empty); 110 87 } 111 public event EventHandler ReadOnlyViewChanged;112 protected virtual void OnReadOnlyViewChanged() {113 EventHandler handler = ReadOnlyViewChanged;114 if (handler != null) handler(this, EventArgs.Empty);115 }116 88 } 117 89 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemSet.cs
r3390 r3431 52 52 } 53 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !((ICollection<T>)set).IsReadOnly) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemSet() 68 : base() { 69 readOnlyView = ((ICollection<T>)set).IsReadOnly; 70 } 71 public ItemSet(IEnumerable<T> collection) 72 : base(collection) { 73 readOnlyView = ((ICollection<T>)set).IsReadOnly; 74 } 54 public ItemSet() : base() { } 55 public ItemSet(IEnumerable<T> collection) : base(collection) { } 75 56 [StorableConstructor] 76 57 protected ItemSet(bool deserializing) { } … … 82 63 ItemSet<T> clone = (ItemSet<T>)Activator.CreateInstance(this.GetType()); 83 64 cloner.RegisterClonedObject(this, clone); 84 clone.readOnlyView = readOnlyView;85 65 clone.set = new HashSet<T>(this.Select(x => (T)cloner.Clone(x))); 86 66 return clone; … … 105 85 if (handler != null) handler(this, EventArgs.Empty); 106 86 } 107 public event EventHandler ReadOnlyViewChanged;108 protected virtual void OnReadOnlyViewChanged() {109 EventHandler handler = ReadOnlyViewChanged;110 if (handler != null) handler(this, EventArgs.Empty);111 }112 87 } 113 88 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/KeyedItemCollection.cs
r3390 r3431 48 48 } 49 49 50 [Storable] 51 private bool readOnlyView; 52 public virtual bool ReadOnlyView { 53 get { return readOnlyView; } 54 set { 55 if ((readOnlyView != value) && !((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly) { 56 readOnlyView = value; 57 OnReadOnlyViewChanged(); 58 OnPropertyChanged("ReadOnlyView"); 59 } 60 } 61 } 62 63 protected KeyedItemCollection() : base() { 64 readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly; 65 } 66 protected KeyedItemCollection(int capacity) : base(capacity) { 67 readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly; 68 } 69 protected KeyedItemCollection(IEnumerable<TItem> collection) : base(collection) { 70 readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly; 71 } 50 protected KeyedItemCollection() : base() { } 51 protected KeyedItemCollection(int capacity) : base(capacity) { } 52 protected KeyedItemCollection(IEnumerable<TItem> collection) : base(collection) { } 72 53 [StorableConstructor] 73 54 protected KeyedItemCollection(bool deserializing) { } … … 79 60 KeyedItemCollection<TKey, TItem> clone = (KeyedItemCollection<TKey, TItem>)Activator.CreateInstance(this.GetType()); 80 61 cloner.RegisterClonedObject(this, clone); 81 clone.readOnlyView = readOnlyView;82 62 foreach (TItem item in dict.Values) { 83 63 TItem clonedItem = (TItem)cloner.Clone(item); … … 105 85 if (handler != null) handler(this, EventArgs.Empty); 106 86 } 107 public event EventHandler ReadOnlyViewChanged;108 protected virtual void OnReadOnlyViewChanged() {109 EventHandler handler = ReadOnlyViewChanged;110 if (handler != null) handler(this, EventArgs.Empty);111 }112 87 } 113 88 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemArray.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 public ReadOnlyItemArray() : base(new ItemArray<T>()) { } 57 52 public ReadOnlyItemArray(IItemArray<T> array) : base(array) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemCollection.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 public ReadOnlyItemCollection() : base(new ItemCollection<T>()) { } 57 52 public ReadOnlyItemCollection(IItemCollection<T> collection) : base(collection) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemDictionary.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 public ReadOnlyItemDictionary() : base(new ItemDictionary<TKey, TValue>()) { } 57 52 public ReadOnlyItemDictionary(IItemDictionary<TKey, TValue> dictionary) : base(dictionary) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemList.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 public ReadOnlyItemList() : base(new ItemList<T>()) { } 57 52 public ReadOnlyItemList(IItemList<T> list) : base(list) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemSet.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 public ReadOnlyItemSet() : base(new ItemSet<T>()) { } 57 52 public ReadOnlyItemSet(IItemSet<T> set) : base(set) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyKeyedItemCollection.cs
r3390 r3431 49 49 } 50 50 51 public bool ReadOnlyView {52 get { return true; }53 set { }54 }55 56 51 protected ReadOnlyKeyedItemCollection() : base() { } 57 52 public ReadOnlyKeyedItemCollection(IKeyedItemCollection<TKey, TItem> collection) : base(collection) { } … … 89 84 if (handler != null) handler(this, EventArgs.Empty); 90 85 } 91 event EventHandler IContent.ReadOnlyViewChanged {92 add { }93 remove { }94 }95 86 } 96 87 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ScopeList.cs
r3390 r3431 38 38 ScopeList clone = new ScopeList(); 39 39 cloner.RegisterClonedObject(this, clone); 40 clone.ReadOnlyView = ReadOnlyView;41 40 clone.list = new List<IScope>(this.Select(x => (IScope)cloner.Clone(x))); 42 41 return clone; -
trunk/sources/HeuristicLab.Core/3.3/Collections/VariableCollection.cs
r3390 r3431 38 38 VariableCollection clone = new VariableCollection(); 39 39 cloner.RegisterClonedObject(this, clone); 40 clone.ReadOnlyView = ReadOnlyView;41 40 foreach (string key in dict.Keys) 42 41 clone.dict.Add(key, (IVariable)cloner.Clone(dict[key]));
Note: See TracChangeset
for help on using the changeset viewer.