Changeset 3317


Ignore:
Timestamp:
04/13/10 06:41:56 (11 years ago)
Author:
swagner
Message:

Implemented ReadOnlyView property for items (#969).

Location:
trunk/sources
Files:
83 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/DataRow.cs

    r3160 r3317  
    5353      DataRow clone = new DataRow(Name, Description);
    5454      cloner.RegisterClonedObject(this, clone);
     55      clone.ReadOnlyView = ReadOnlyView;
    5556      clone.values.AddRange(values);
    5657      return clone;
  • trunk/sources/HeuristicLab.Analysis/3.3/DataTable.cs

    r3306 r3317  
    5757      DataTable clone = new DataTable(Name, Description);
    5858      cloner.RegisterClonedObject(this, clone);
     59      clone.ReadOnlyView = ReadOnlyView;
    5960      clone.rows = (NamedItemCollection<DataRow>)cloner.Clone(rows);
    6061      return clone;
  • trunk/sources/HeuristicLab.Collections/3.3/IObservableArray.cs

    r2832 r3317  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.ComponentModel;
     
    2526namespace HeuristicLab.Collections {
    2627  public interface IObservableArray<T> : IList<T>, INotifyObservableArrayItemsChanged<T>, INotifyPropertyChanged {
     28    bool ReadOnlyView { get; set; }
    2729    int Length { get; }
     30
     31    event EventHandler ReadOnlyViewChanged;
    2832  }
    2933}
  • trunk/sources/HeuristicLab.Collections/3.3/IObservableCollection.cs

    r2832 r3317  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.ComponentModel;
    2425
    2526namespace HeuristicLab.Collections {
    26   public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged { }
     27  public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged {
     28    bool ReadOnlyView { get; set; }
     29
     30    event EventHandler ReadOnlyViewChanged;
     31  }
    2732}
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableArray.cs

    r3286 r3317  
    3535
    3636    #region Properties
     37    [Storable]
     38    private bool readOnlyView;
     39    public bool ReadOnlyView {
     40      get { return readOnlyView; }
     41      set {
     42        if (readOnlyView != value) {
     43          readOnlyView = value;
     44          OnReadOnlyViewChanged();
     45          OnPropertyChanged("ReadOnlyView");
     46        }
     47      }
     48    }
     49
    3750    public int Length {
    3851      get { return array.Length; }
     
    6376    public ObservableArray() {
    6477      array = new T[0];
     78      readOnlyView = array.IsReadOnly;
    6579    }
    6680    public ObservableArray(int length) {
    6781      array = new T[length];
     82      readOnlyView = array.IsReadOnly;
    6883    }
    6984    public ObservableArray(T[] array) {
    7085      this.array = (T[])array.Clone();
     86      readOnlyView = array.IsReadOnly;
    7187    }
    7288    public ObservableArray(IEnumerable<T> collection) {
    7389      array = collection.ToArray();
     90      readOnlyView = array.IsReadOnly;
    7491    }
    7592    #endregion
     
    281298    #region Events
    282299    [field: NonSerialized]
     300    public event EventHandler ReadOnlyViewChanged;
     301    protected virtual void OnReadOnlyViewChanged() {
     302      EventHandler handler = ReadOnlyViewChanged;
     303      if (handler != null) handler(this, EventArgs.Empty);
     304    }
     305
     306    [field: NonSerialized]
    283307    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced;
    284308    protected virtual void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    285       if (ItemsReplaced != null)
    286         ItemsReplaced(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     309      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsReplaced;
     310      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    287311    }
    288312
     
    290314    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsMoved;
    291315    protected virtual void OnItemsMoved(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    292       if (ItemsMoved != null)
    293         ItemsMoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     316      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsMoved;
     317      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    294318    }
    295319
     
    297321    public event CollectionItemsChangedEventHandler<IndexedItem<T>> CollectionReset;
    298322    protected virtual void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    299       if (CollectionReset != null)
    300         CollectionReset(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     323      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = CollectionReset;
     324      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    301325    }
    302326
     
    304328    public event PropertyChangedEventHandler PropertyChanged;
    305329    protected virtual void OnPropertyChanged(string propertyName) {
    306       if (PropertyChanged != null)
    307         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     330      PropertyChangedEventHandler handler = PropertyChanged;
     331      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    308332    }
    309333    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableCollection.cs

    r3286 r3317  
    3434
    3535    #region Properties
     36    [Storable]
     37    private bool readOnlyView;
     38    public bool ReadOnlyView {
     39      get { return readOnlyView; }
     40      set {
     41        if (readOnlyView != value) {
     42          readOnlyView = value;
     43          OnReadOnlyViewChanged();
     44          OnPropertyChanged("ReadOnlyView");
     45        }
     46      }
     47    }
     48
    3649    public int Capacity {
    3750      get { return list.Capacity; }
     
    5467    public ObservableCollection() {
    5568      list = new List<T>();
     69      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    5670    }
    5771    public ObservableCollection(int capacity) {
    5872      list = new List<T>(capacity);
     73      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    5974    }
    6075    public ObservableCollection(IEnumerable<T> collection) {
    6176      list = new List<T>(collection);
     77      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    6278    }
    6379    #endregion
     
    189205    #region Events
    190206    [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]
    191214    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    192215    protected virtual void OnItemsAdded(IEnumerable<T> items) {
    193       if (ItemsAdded != null)
    194         ItemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     216      CollectionItemsChangedEventHandler<T> handler = ItemsAdded;
     217      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    195218    }
    196219
     
    198221    public event CollectionItemsChangedEventHandler<T> ItemsRemoved;
    199222    protected virtual void OnItemsRemoved(IEnumerable<T> items) {
    200       if (ItemsRemoved != null)
    201         ItemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     223      CollectionItemsChangedEventHandler<T> handler = ItemsRemoved;
     224      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    202225    }
    203226
     
    205228    public event CollectionItemsChangedEventHandler<T> CollectionReset;
    206229    protected virtual void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    207       if (CollectionReset != null)
    208         CollectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     230      CollectionItemsChangedEventHandler<T> handler = CollectionReset;
     231      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    209232    }
    210233
     
    212235    public event PropertyChangedEventHandler PropertyChanged;
    213236    protected virtual void OnPropertyChanged(string propertyName) {
    214       if (PropertyChanged != null)
    215         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     237      PropertyChangedEventHandler handler = PropertyChanged;
     238      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    216239    }
    217240    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableDictionary.cs

    r3017 r3317  
    3535
    3636    #region Properties
     37    [Storable]
     38    private bool readOnlyView;
     39    public bool ReadOnlyView {
     40      get { return readOnlyView; }
     41      set {
     42        if (readOnlyView != value) {
     43          readOnlyView = value;
     44          OnReadOnlyViewChanged();
     45          OnPropertyChanged("ReadOnlyView");
     46        }
     47      }
     48    }
     49
    3750    public ICollection<TKey> Keys {
    3851      get { return dict.Keys; }
     
    7184    public ObservableDictionary() {
    7285      dict = new Dictionary<TKey, TValue>();
     86      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    7387    }
    7488    public ObservableDictionary(int capacity) {
    7589      dict = new Dictionary<TKey, TValue>(capacity);
     90      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    7691    }
    7792    public ObservableDictionary(IEqualityComparer<TKey> comparer) {
    7893      dict = new Dictionary<TKey, TValue>(comparer);
     94      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    7995    }
    8096    public ObservableDictionary(IDictionary<TKey, TValue> dictionary) {
    8197      dict = new Dictionary<TKey, TValue>(dictionary);
     98      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    8299    }
    83100    public ObservableDictionary(int capacity, IEqualityComparer<TKey> comparer) {
    84101      dict = new Dictionary<TKey, TValue>(capacity, comparer);
     102      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    85103    }
    86104    public ObservableDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer) {
    87105      dict = new Dictionary<TKey, TValue>(dictionary, comparer);
     106      readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    88107    }
    89108    #endregion
     
    181200    #region Events
    182201    [field: NonSerialized]
     202    public event EventHandler ReadOnlyViewChanged;
     203    protected virtual void OnReadOnlyViewChanged() {
     204      EventHandler handler = ReadOnlyViewChanged;
     205      if (handler != null) handler(this, EventArgs.Empty);
     206    }
     207
     208    [field: NonSerialized]
    183209    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsAdded;
    184210    protected virtual void OnItemsAdded(IEnumerable<KeyValuePair<TKey, TValue>> items) {
    185       if (ItemsAdded != null)
    186         ItemsAdded(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     211      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsAdded;
     212      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
    187213    }
    188214
     
    190216    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsRemoved;
    191217    protected virtual void OnItemsRemoved(IEnumerable<KeyValuePair<TKey, TValue>> items) {
    192       if (ItemsRemoved != null)
    193         ItemsRemoved(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     218      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsRemoved;
     219      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
    194220    }
    195221
     
    197223    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsReplaced;
    198224    protected virtual void OnItemsReplaced(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
    199       if (ItemsReplaced != null)
    200         ItemsReplaced(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     225      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsReplaced;
     226      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
    201227    }
    202228
     
    204230    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> CollectionReset;
    205231    protected virtual void OnCollectionReset(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
    206       if (CollectionReset != null)
    207         CollectionReset(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     232      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = CollectionReset;
     233      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
    208234    }
    209235
     
    211237    public event PropertyChangedEventHandler PropertyChanged;
    212238    protected virtual void OnPropertyChanged(string propertyName) {
    213       if (PropertyChanged != null)
    214         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     239      PropertyChangedEventHandler handler = PropertyChanged;
     240      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    215241    }
    216242    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableKeyedCollection.cs

    r3286 r3317  
    3535
    3636    #region Properties
     37    [Storable]
     38    private bool readOnlyView;
     39    public bool ReadOnlyView {
     40      get { return readOnlyView; }
     41      set {
     42        if (readOnlyView != value) {
     43          readOnlyView = value;
     44          OnReadOnlyViewChanged();
     45          OnPropertyChanged("ReadOnlyView");
     46        }
     47      }
     48    }
     49
    3750    public int Count {
    3851      get { return dict.Count; }
     
    5568    protected ObservableKeyedCollection() {
    5669      dict = new Dictionary<TKey, TItem>();
     70      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    5771    }
    5872    protected ObservableKeyedCollection(int capacity) {
    5973      dict = new Dictionary<TKey, TItem>(capacity);
     74      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    6075    }
    6176    protected ObservableKeyedCollection(IEqualityComparer<TKey> comparer) {
    6277      dict = new Dictionary<TKey, TItem>(comparer);
     78      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    6379    }
    6480    protected ObservableKeyedCollection(IEnumerable<TItem> collection) {
     
    6783      foreach (TItem item in collection)
    6884        dict.Add(GetKeyForItem(item), item);
     85      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    6986    }
    7087    protected ObservableKeyedCollection(int capacity, IEqualityComparer<TKey> comparer) {
    7188      dict = new Dictionary<TKey, TItem>(capacity, comparer);
     89      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    7290    }
    7391    protected ObservableKeyedCollection(IEnumerable<TItem> collection, IEqualityComparer<TKey> comparer) {
     
    7694      foreach (TItem item in collection)
    7795        dict.Add(GetKeyForItem(item), item);
     96      readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    7897    }
    7998    #endregion
     
    250269    #region Events
    251270    [field: NonSerialized]
     271    public event EventHandler ReadOnlyViewChanged;
     272    protected virtual void OnReadOnlyViewChanged() {
     273      EventHandler handler = ReadOnlyViewChanged;
     274      if (handler != null) handler(this, EventArgs.Empty);
     275    }
     276
     277    [field: NonSerialized]
    252278    public event CollectionItemsChangedEventHandler<TItem> ItemsAdded;
    253279    protected virtual void OnItemsAdded(IEnumerable<TItem> items) {
    254       if (ItemsAdded != null)
    255         ItemsAdded(this, new CollectionItemsChangedEventArgs<TItem>(items));
     280      CollectionItemsChangedEventHandler<TItem> handler = ItemsAdded;
     281      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items));
    256282    }
    257283
     
    259285    public event CollectionItemsChangedEventHandler<TItem> ItemsRemoved;
    260286    protected virtual void OnItemsRemoved(IEnumerable<TItem> items) {
    261       if (ItemsRemoved != null)
    262         ItemsRemoved(this, new CollectionItemsChangedEventArgs<TItem>(items));
     287      CollectionItemsChangedEventHandler<TItem> handler = ItemsRemoved;
     288      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items));
    263289    }
    264290
     
    266292    public event CollectionItemsChangedEventHandler<TItem> ItemsReplaced;
    267293    protected virtual void OnItemsReplaced(IEnumerable<TItem> items, IEnumerable<TItem> oldItems) {
    268       if (ItemsReplaced != null)
    269         ItemsReplaced(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
     294      CollectionItemsChangedEventHandler<TItem> handler = ItemsReplaced;
     295      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
    270296    }
    271297
     
    273299    public event CollectionItemsChangedEventHandler<TItem> CollectionReset;
    274300    protected virtual void OnCollectionReset(IEnumerable<TItem> items, IEnumerable<TItem> oldItems) {
    275       if (CollectionReset != null)
    276         CollectionReset(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
     301      CollectionItemsChangedEventHandler<TItem> handler = CollectionReset;
     302      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
    277303    }
    278304
     
    280306    public event PropertyChangedEventHandler PropertyChanged;
    281307    protected virtual void OnPropertyChanged(string propertyName) {
    282       if (PropertyChanged != null)
    283         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     308      PropertyChangedEventHandler handler = PropertyChanged;
     309      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    284310    }
    285311    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs

    r3286 r3317  
    3434
    3535    #region Properties
     36    [Storable]
     37    private bool readOnlyView;
     38    public bool ReadOnlyView {
     39      get { return readOnlyView; }
     40      set {
     41        if (readOnlyView != value) {
     42          readOnlyView = value;
     43          OnReadOnlyViewChanged();
     44          OnPropertyChanged("ReadOnlyView");
     45        }
     46      }
     47    }
     48
    3649    public int Capacity {
    3750      get { return list.Capacity; }
     
    6881    public ObservableList() {
    6982      list = new List<T>();
     83      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7084    }
    7185    public ObservableList(int capacity) {
    7286      list = new List<T>(capacity);
     87      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7388    }
    7489    public ObservableList(IEnumerable<T> collection) {
    7590      list = new List<T>(collection);
     91      readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7692    }
    7793    #endregion
     
    375391    #region Events
    376392    [field: NonSerialized]
     393    public event EventHandler ReadOnlyViewChanged;
     394    protected virtual void OnReadOnlyViewChanged() {
     395      EventHandler handler = ReadOnlyViewChanged;
     396      if (handler != null) handler(this, EventArgs.Empty);
     397    }
     398
     399    [field: NonSerialized]
    377400    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded;
    378401    protected virtual void OnItemsAdded(IEnumerable<IndexedItem<T>> items) {
    379       if (ItemsAdded != null)
    380         ItemsAdded(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
     402      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsAdded;
     403      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
    381404    }
    382405
     
    388411    }
    389412    private void OnItemsAdded(IEnumerable<T> items) {
    390       if (itemsAdded != null)
    391         itemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     413      CollectionItemsChangedEventHandler<T> handler = itemsAdded;
     414      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    392415    }
    393416
     
    395418    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsRemoved;
    396419    protected virtual void OnItemsRemoved(IEnumerable<IndexedItem<T>> items) {
    397       if (ItemsRemoved != null)
    398         ItemsRemoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
     420      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsRemoved;
     421      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
    399422    }
    400423
     
    406429    }
    407430    private void OnItemsRemoved(IEnumerable<T> items) {
    408       if (itemsRemoved != null)
    409         itemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     431      CollectionItemsChangedEventHandler<T> handler = itemsRemoved;
     432      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    410433    }
    411434
     
    413436    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced;
    414437    protected virtual void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    415       if (ItemsReplaced != null)
    416         ItemsReplaced(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     438      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsReplaced;
     439      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    417440    }
    418441
     
    420443    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsMoved;
    421444    protected virtual void OnItemsMoved(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    422       if (ItemsMoved != null)
    423         ItemsMoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     445      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsMoved;
     446      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    424447    }
    425448
     
    427450    public event CollectionItemsChangedEventHandler<IndexedItem<T>> CollectionReset;
    428451    protected virtual void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    429       if (CollectionReset != null)
    430         CollectionReset(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     452      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = CollectionReset;
     453      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    431454    }
    432455
     
    438461    }
    439462    private void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    440       if (collectionReset != null)
    441         collectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     463      CollectionItemsChangedEventHandler<T> handler = collectionReset;
     464      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    442465    }
    443466
     
    445468    public event PropertyChangedEventHandler PropertyChanged;
    446469    protected virtual void OnPropertyChanged(string propertyName) {
    447       if (PropertyChanged != null)
    448         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     470      PropertyChangedEventHandler handler = PropertyChanged;
     471      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    449472    }
    450473    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableSet.cs

    r3286 r3317  
    3535
    3636    #region Properties
     37    [Storable]
     38    private bool readOnlyView;
     39    public bool ReadOnlyView {
     40      get { return readOnlyView; }
     41      set {
     42        if (readOnlyView != value) {
     43          readOnlyView = value;
     44          OnReadOnlyViewChanged();
     45          OnPropertyChanged("ReadOnlyView");
     46        }
     47      }
     48    }
     49
    3750    public IEqualityComparer<T> Comparer {
    3851      get { return set.Comparer; }
     
    4962    public ObservableSet() {
    5063      set = new HashSet<T>();
     64      readOnlyView = ((ICollection<T>)set).IsReadOnly;
    5165    }
    5266    public ObservableSet(IEnumerable<T> collection) {
    5367      set = new HashSet<T>(collection);
     68      readOnlyView = ((ICollection<T>)set).IsReadOnly;
    5469    }
    5570    public ObservableSet(IEqualityComparer<T> comparer) {
    5671      set = new HashSet<T>(comparer);
     72      readOnlyView = ((ICollection<T>)set).IsReadOnly;
    5773    }
    5874    public ObservableSet(IEnumerable<T> collection, IEqualityComparer<T> comparer) {
    5975      set = new HashSet<T>(collection, comparer);
     76      readOnlyView = ((ICollection<T>)set).IsReadOnly;
    6077    }
    6178    #endregion
     
    227244    #region Events
    228245    [field: NonSerialized]
     246    public event EventHandler ReadOnlyViewChanged;
     247    protected virtual void OnReadOnlyViewChanged() {
     248      EventHandler handler = ReadOnlyViewChanged;
     249      if (handler != null) handler(this, EventArgs.Empty);
     250    }
     251
     252    [field: NonSerialized]
    229253    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    230254    protected virtual void OnItemsAdded(IEnumerable<T> items) {
    231       if (ItemsAdded != null)
    232         ItemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     255      CollectionItemsChangedEventHandler<T> handler = ItemsAdded;
     256      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    233257    }
    234258
     
    236260    public event CollectionItemsChangedEventHandler<T> ItemsRemoved;
    237261    protected virtual void OnItemsRemoved(IEnumerable<T> items) {
    238       if (ItemsRemoved != null)
    239         ItemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     262      CollectionItemsChangedEventHandler<T> handler = ItemsRemoved;
     263      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    240264    }
    241265
     
    243267    public event CollectionItemsChangedEventHandler<T> CollectionReset;
    244268    protected virtual void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    245       if (CollectionReset != null)
    246         CollectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     269      CollectionItemsChangedEventHandler<T> handler = CollectionReset;
     270      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    247271    }
    248272
     
    250274    public event PropertyChangedEventHandler PropertyChanged;
    251275    protected virtual void OnPropertyChanged(string propertyName) {
    252       if (PropertyChanged != null)
    253         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     276      PropertyChangedEventHandler handler = PropertyChanged;
     277      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    254278    }
    255279    #endregion
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableArray.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public int Length {
    3742      get { return array.Length; }
     
    117122    }
    118123
     124    event EventHandler IObservableArray<T>.ReadOnlyViewChanged {
     125      add { }
     126      remove { }
     127    }
     128
    119129    [field: NonSerialized]
    120130    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced;
    121131    protected virtual void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    122       if (ItemsReplaced != null)
    123         ItemsReplaced(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     132      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsReplaced;
     133      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    124134    }
    125135
     
    127137    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsMoved;
    128138    protected virtual void OnItemsMoved(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    129       if (ItemsMoved != null)
    130         ItemsMoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     139      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsMoved;
     140      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    131141    }
    132142
     
    134144    public event CollectionItemsChangedEventHandler<IndexedItem<T>> CollectionReset;
    135145    protected virtual void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    136       if (CollectionReset != null)
    137         CollectionReset(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     146      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = CollectionReset;
     147      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    138148    }
    139149
     
    141151    public event PropertyChangedEventHandler PropertyChanged;
    142152    protected virtual void OnPropertyChanged(string propertyName) {
    143       if (PropertyChanged != null)
    144         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     153      PropertyChangedEventHandler handler = PropertyChanged;
     154      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    145155    }
    146156
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableCollection.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public int Count {
    3742      get { return collection.Count; }
     
    95100    }
    96101
     102    event EventHandler IObservableCollection<T>.ReadOnlyViewChanged {
     103      add { }
     104      remove { }
     105    }
     106
    97107    [field: NonSerialized]
    98108    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    99109    protected virtual void OnItemsAdded(IEnumerable<T> items) {
    100       if (ItemsAdded != null)
    101         ItemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     110      CollectionItemsChangedEventHandler<T> handler = ItemsAdded;
     111      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    102112    }
    103113
     
    105115    public event CollectionItemsChangedEventHandler<T> ItemsRemoved;
    106116    protected virtual void OnItemsRemoved(IEnumerable<T> items) {
    107       if (ItemsRemoved != null)
    108         ItemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     117      CollectionItemsChangedEventHandler<T> handler = ItemsRemoved;
     118      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    109119    }
    110120
     
    112122    public event CollectionItemsChangedEventHandler<T> CollectionReset;
    113123    protected virtual void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    114       if (CollectionReset != null)
    115         CollectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     124      CollectionItemsChangedEventHandler<T> handler = CollectionReset;
     125      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    116126    }
    117127
     
    119129    public event PropertyChangedEventHandler PropertyChanged;
    120130    protected virtual void OnPropertyChanged(string propertyName) {
    121       if (PropertyChanged != null)
    122         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     131      PropertyChangedEventHandler handler = PropertyChanged;
     132      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    123133    }
    124134
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableDictionary.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public ICollection<TKey> Keys {
    3742      get { return dict.Keys; }
     
    123128    }
    124129
     130    event EventHandler IObservableCollection<KeyValuePair<TKey, TValue>>.ReadOnlyViewChanged {
     131      add { }
     132      remove { }
     133    }
     134
    125135    [field: NonSerialized]
    126136    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsAdded;
    127137    protected virtual void OnItemsAdded(IEnumerable<KeyValuePair<TKey, TValue>> items) {
    128       if (ItemsAdded != null)
    129         ItemsAdded(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     138      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsAdded;
     139      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
    130140    }
    131141
     
    133143    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsRemoved;
    134144    protected virtual void OnItemsRemoved(IEnumerable<KeyValuePair<TKey, TValue>> items) {
    135       if (ItemsRemoved != null)
    136         ItemsRemoved(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     145      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsRemoved;
     146      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
    137147    }
    138148
     
    140150    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsReplaced;
    141151    protected virtual void OnItemsReplaced(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
    142       if (ItemsReplaced != null)
    143         ItemsReplaced(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     152      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = ItemsReplaced;
     153      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
    144154    }
    145155
     
    147157    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> CollectionReset;
    148158    protected virtual void OnCollectionReset(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
    149       if (CollectionReset != null)
    150         CollectionReset(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     159      CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> handler = CollectionReset;
     160      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
    151161    }
    152162
     
    154164    public event PropertyChangedEventHandler PropertyChanged;
    155165    protected virtual void OnPropertyChanged(string propertyName) {
    156       if (PropertyChanged != null)
    157         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     166      PropertyChangedEventHandler handler = PropertyChanged;
     167      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    158168    }
    159169
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableKeyedCollection.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public int Count {
    3742      get { return collection.Count; }
     
    112117    }
    113118
     119    event EventHandler IObservableCollection<TItem>.ReadOnlyViewChanged {
     120      add { }
     121      remove { }
     122    }
     123
    114124    [field: NonSerialized]
    115125    public event CollectionItemsChangedEventHandler<TItem> ItemsAdded;
    116126    protected virtual void OnItemsAdded(IEnumerable<TItem> items) {
    117       if (ItemsAdded != null)
    118         ItemsAdded(this, new CollectionItemsChangedEventArgs<TItem>(items));
     127      CollectionItemsChangedEventHandler<TItem> handler = ItemsAdded;
     128      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items));
    119129    }
    120130
     
    122132    public event CollectionItemsChangedEventHandler<TItem> ItemsRemoved;
    123133    protected virtual void OnItemsRemoved(IEnumerable<TItem> items) {
    124       if (ItemsRemoved != null)
    125         ItemsRemoved(this, new CollectionItemsChangedEventArgs<TItem>(items));
     134      CollectionItemsChangedEventHandler<TItem> handler = ItemsRemoved;
     135      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items));
    126136    }
    127137
     
    129139    public event CollectionItemsChangedEventHandler<TItem> ItemsReplaced;
    130140    protected virtual void OnItemsReplaced(IEnumerable<TItem> items, IEnumerable<TItem> oldItems) {
    131       if (ItemsReplaced != null)
    132         ItemsReplaced(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
     141      CollectionItemsChangedEventHandler<TItem> handler = ItemsReplaced;
     142      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
    133143    }
    134144
     
    136146    public event CollectionItemsChangedEventHandler<TItem> CollectionReset;
    137147    protected virtual void OnCollectionReset(IEnumerable<TItem> items, IEnumerable<TItem> oldItems) {
    138       if (CollectionReset != null)
    139         CollectionReset(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
     148      CollectionItemsChangedEventHandler<TItem> handler = CollectionReset;
     149      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<TItem>(items, oldItems));
    140150    }
    141151
     
    143153    public event PropertyChangedEventHandler PropertyChanged;
    144154    protected virtual void OnPropertyChanged(string propertyName) {
    145       if (PropertyChanged != null)
    146         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     155      PropertyChangedEventHandler handler = PropertyChanged;
     156      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    147157    }
    148158
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableList.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public int Count {
    3742      get { return ((ICollection<T>)list).Count; }
     
    119124    }
    120125
     126    event EventHandler IObservableCollection<T>.ReadOnlyViewChanged {
     127      add { }
     128      remove { }
     129    }
     130
    121131    [field: NonSerialized]
    122132    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded;
    123133    protected virtual void OnItemsAdded(IEnumerable<IndexedItem<T>> items) {
    124       if (ItemsAdded != null)
    125         ItemsAdded(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
     134      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsAdded;
     135      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
    126136    }
    127137
     
    133143    }
    134144    private void OnItemsAdded(IEnumerable<T> items) {
    135       if (itemsAdded != null)
    136         itemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     145      CollectionItemsChangedEventHandler<T> handler = itemsAdded;
     146      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    137147    }
    138148
     
    140150    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsRemoved;
    141151    protected virtual void OnItemsRemoved(IEnumerable<IndexedItem<T>> items) {
    142       if (ItemsRemoved != null)
    143         ItemsRemoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
     152      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsRemoved;
     153      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items));
    144154    }
    145155
     
    151161    }
    152162    private void OnItemsRemoved(IEnumerable<T> items) {
    153       if (itemsRemoved != null)
    154         itemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     163      CollectionItemsChangedEventHandler<T> handler = itemsRemoved;
     164      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    155165    }
    156166
     
    158168    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced;
    159169    protected virtual void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    160       if (ItemsReplaced != null)
    161         ItemsReplaced(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     170      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsReplaced;
     171      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    162172    }
    163173
     
    165175    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsMoved;
    166176    protected virtual void OnItemsMoved(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    167       if (ItemsMoved != null)
    168         ItemsMoved(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     177      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = ItemsMoved;
     178      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    169179    }
    170180
     
    172182    public event CollectionItemsChangedEventHandler<IndexedItem<T>> CollectionReset;
    173183    protected virtual void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    174       if (CollectionReset != null)
    175         CollectionReset(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
     184      CollectionItemsChangedEventHandler<IndexedItem<T>> handler = CollectionReset;
     185      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<IndexedItem<T>>(items, oldItems));
    176186    }
    177187
     
    183193    }
    184194    private void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    185       if (collectionReset != null)
    186         collectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     195      CollectionItemsChangedEventHandler<T> handler = collectionReset;
     196      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    187197    }
    188198
     
    190200    public event PropertyChangedEventHandler PropertyChanged;
    191201    protected virtual void OnPropertyChanged(string propertyName) {
    192       if (PropertyChanged != null)
    193         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     202      PropertyChangedEventHandler handler = PropertyChanged;
     203      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    194204    }
    195205
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableSet.cs

    r3019 r3317  
    3434
    3535    #region Properties
     36    public bool ReadOnlyView {
     37      get { return true; }
     38      set { throw new NotSupportedException(); }
     39    }
     40
    3641    public int Count {
    3742      get { return set.Count; }
     
    136141    }
    137142
     143    event EventHandler IObservableCollection<T>.ReadOnlyViewChanged {
     144      add { }
     145      remove { }
     146    }
     147
    138148    [field: NonSerialized]
    139149    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    140150    protected virtual void OnItemsAdded(IEnumerable<T> items) {
    141       if (ItemsAdded != null)
    142         ItemsAdded(this, new CollectionItemsChangedEventArgs<T>(items));
     151      CollectionItemsChangedEventHandler<T> handler = ItemsAdded;
     152      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    143153    }
    144154
     
    146156    public event CollectionItemsChangedEventHandler<T> ItemsRemoved;
    147157    protected virtual void OnItemsRemoved(IEnumerable<T> items) {
    148       if (ItemsRemoved != null)
    149         ItemsRemoved(this, new CollectionItemsChangedEventArgs<T>(items));
     158      CollectionItemsChangedEventHandler<T> handler = ItemsRemoved;
     159      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items));
    150160    }
    151161
     
    153163    public event CollectionItemsChangedEventHandler<T> CollectionReset;
    154164    protected virtual void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    155       if (CollectionReset != null)
    156         CollectionReset(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
     165      CollectionItemsChangedEventHandler<T> handler = CollectionReset;
     166      if (handler != null) handler(this, new CollectionItemsChangedEventArgs<T>(items, oldItems));
    157167    }
    158168
     
    160170    public event PropertyChangedEventHandler PropertyChanged;
    161171    protected virtual void OnPropertyChanged(string propertyName) {
    162       if (PropertyChanged != null)
    163         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     172      PropertyChangedEventHandler handler = PropertyChanged;
     173      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    164174    }
    165175
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r3306 r3317  
    280280      T item = (T)listViewItem.Tag;
    281281      int i = 0;
    282       while ((i < itemsListView.SmallImageList.Images.Count) && (item.ItemImage != itemsListView.SmallImageList.Images[i]))
     282      while ((i < itemsListView.SmallImageList.Images.Count) && !item.ItemImage.Equals(itemsListView.SmallImageList.Images[i]))
    283283        i++;
    284284      if (i == itemsListView.SmallImageList.Images.Count) itemsListView.SmallImageList.Images.Add(item.ItemImage);
  • trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs

    r3017 r3317  
    2626namespace HeuristicLab.Core {
    2727  [StorableClass]
    28   public class ExecutionContext : DeepCloneable, IExecutionContext, IAtomicOperation {
     28  public sealed class ExecutionContext : DeepCloneable, IExecutionContext, IAtomicOperation {
    2929    [Storable]
    3030    private IParameterizedItem parameterizedItem;
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IItem.cs

    r3306 r3317  
    3232    Image ItemImage { get; }
    3333
     34    bool ReadOnlyView { get; set; }
     35
    3436    event EventHandler ItemImageChanged;
     37    event EventHandler ReadOnlyViewChanged;
    3538    event EventHandler ToStringChanged;
    3639  }
  • trunk/sources/HeuristicLab.Core/3.3/Item.cs

    r3306 r3317  
    2222using System;
    2323using System.Drawing;
    24 using HeuristicLab.Common.Resources;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625
     
    3938    }
    4039    public virtual Image ItemImage {
    41       get { return VS2008ImageLibrary.Class; }
     40      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; }
    4241    }
    4342
    44     protected Item() : base() { }
     43    [Storable]
     44    private bool readOnlyView;
     45    public bool ReadOnlyView {
     46      get { return readOnlyView; }
     47      set {
     48        if (readOnlyView != value) {
     49          readOnlyView = value;
     50          OnReadOnlyViewChanged();
     51        }
     52      }
     53    }
     54
     55    protected Item()
     56      : base() {
     57      readOnlyView = false;
     58    }
    4559    [StorableConstructor]
    4660    protected Item(bool deserializing) : base(deserializing) { }
    4761
     62
     63    /// <summary>
     64    /// Clones the current instance (deep clone).
     65    /// </summary>
     66    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
     67    /// <returns>The cloned object as <see cref="Variable"/>.</returns>
     68    public override IDeepCloneable Clone(Cloner cloner) {
     69      Item clone = (Item)base.Clone(cloner);
     70      clone.readOnlyView = readOnlyView;
     71      return clone;
     72    }
    4873
    4974    /// <summary>
     
    6085      if (handler != null) handler(this, EventArgs.Empty);
    6186    }
     87    public event EventHandler ReadOnlyViewChanged;
     88    protected virtual void OnReadOnlyViewChanged() {
     89      EventHandler handler = ReadOnlyViewChanged;
     90      if (handler != null) handler(this, EventArgs.Empty);
     91    }
    6292    public event EventHandler ToStringChanged;
    6393    protected virtual void OnToStringChanged() {
  • trunk/sources/HeuristicLab.Core/3.3/ItemArray.cs

    r3306 r3317  
    5757      ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType());
    5858      cloner.RegisterClonedObject(this, clone);
     59      clone.ReadOnlyView = ReadOnlyView;
    5960      clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray();
    6061      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/ItemCollection.cs

    r3306 r3317  
    5353      ItemCollection<T> clone = (ItemCollection<T>)Activator.CreateInstance(this.GetType());
    5454      cloner.RegisterClonedObject(this, clone);
     55      clone.ReadOnlyView = ReadOnlyView;
    5556      clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    5657      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/ItemList.cs

    r3306 r3317  
    5757      ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType());
    5858      cloner.RegisterClonedObject(this, clone);
     59      clone.ReadOnlyView = ReadOnlyView;
    5960      clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    6061      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/ItemSet.cs

    r3306 r3317  
    5656      ItemSet<T> clone = (ItemSet<T>)Activator.CreateInstance(this.GetType());
    5757      cloner.RegisterClonedObject(this, clone);
     58      clone.ReadOnlyView = ReadOnlyView;
    5859      clone.set = new HashSet<T>(this.Select(x => (T)cloner.Clone(x)));
    5960      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/NamedItemCollection.cs

    r3306 r3317  
    4949
    5050    [StorableHook(HookType.AfterDeserialization)]
    51     private void Initialize() {
     51    protected void Initialize() {
    5252      RegisterItemEvents(this);
    5353    }
     
    5959      NamedItemCollection<T> clone = (NamedItemCollection<T>)Activator.CreateInstance(this.GetType());
    6060      cloner.RegisterClonedObject(this, clone);
     61      clone.ReadOnlyView = ReadOnlyView;
    6162      foreach (string key in dict.Keys)
    6263        clone.dict.Add(key, (T)cloner.Clone(dict[key]));
  • trunk/sources/HeuristicLab.Core/3.3/OperationCollection.cs

    r3017 r3317  
    2626namespace HeuristicLab.Core {
    2727  [StorableClass]
    28   public class OperationCollection : DeepCloneable, IList<IOperation>, IOperation {
     28  public sealed class OperationCollection : DeepCloneable, IList<IOperation>, IOperation {
    2929    [Storable]
    3030    private IList<IOperation> operations;
     
    5151
    5252    public override IDeepCloneable Clone(Cloner cloner) {
    53       OperationCollection clone = new OperationCollection(this.Select(x => (IOperation)cloner.Clone(x)));
    54       cloner.RegisterClonedObject(this, clone);
     53      OperationCollection clone = (OperationCollection)base.Clone(cloner);
     54      clone.operations = new List<IOperation>(this.Select(x => (IOperation)cloner.Clone(x)));
    5555      clone.parallel = parallel;
    5656      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs

    r3160 r3317  
    3737  [StorableClass]
    3838  public class OperatorGraph : Item {
     39    [Storable]
    3940    private OperatorSet operators;
    4041    /// <summary>
    4142    /// Gets all operators of the current instance.
    4243    /// </summary>
    43     [Storable]
    4444    public OperatorSet Operators {
    4545      get { return operators; }
    46       private set {
    47         DeregisterOperatorsEvents();
    48         operators = value;
    49         RegisterOperatorsEvents();
    50       }
    5146    }
    5247
     
    8782    /// </summary>
    8883    public OperatorGraph() {
    89       Operators = new OperatorSet();
     84      operators = new OperatorSet();
    9085      initialOperator = null;
    9186      visualizationInfo = null;
     87      Initialize();
     88    }
     89    [StorableConstructor]
     90    protected OperatorGraph(bool deserializing) : base(deserializing) { }
     91
     92    [StorableHook(HookType.AfterDeserialization)]
     93    private void Initialize() {
     94      RegisterOperatorsEvents();
    9295    }
    9396
     
    100103    /// <returns>The cloned object as <see cref="OperatorGraph"/>.</returns>
    101104    public override IDeepCloneable Clone(Cloner cloner) {
    102       OperatorGraph clone = new OperatorGraph();
    103       cloner.RegisterClonedObject(this, clone);
    104       clone.Operators = (OperatorSet)cloner.Clone(operators);
     105      OperatorGraph clone = (OperatorGraph)base.Clone(cloner);
     106      clone.operators = (OperatorSet)cloner.Clone(operators);
    105107      clone.initialOperator = (IOperator)cloner.Clone(initialOperator);
    106108      clone.visualizationInfo = cloner.Clone(visualizationInfo);
     109      clone.Initialize();
    107110      return clone;
    108111    }
     
    166169      }
    167170    }
    168     private void DeregisterOperatorsEvents() {
    169       if (operators != null) {
    170         foreach (IOperator op in operators) {
    171           foreach (IParameter param in op.Parameters) {
    172             IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    173             if (opParam != null) DeregisterOperatorParameterEvents(opParam);
    174           }
    175           DeregisterOperatorEvents(op);
    176         }
    177         operators.ItemsAdded -= new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
    178         operators.ItemsRemoved -= new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved);
    179         operators.CollectionReset -= new CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset);
    180       }
    181     }
    182171    private void RegisterOperatorEvents(IOperator op) {
    183172      op.Parameters.ItemsAdded += new CollectionItemsChangedEventHandler<IParameter>(Parameters_ItemsAdded);
  • trunk/sources/HeuristicLab.Core/3.3/Scope.cs

    r3280 r3317  
    5151    }
    5252
     53    [Storable]
    5354    private ScopeList subScopes;
    54     [Storable]
    5555    public ScopeList SubScopes {
    5656      get { return subScopes; }
    57       private set {
    58         DeregisterSubScopesEvents();
    59         subScopes = value;
    60         RegisterSubScopesEvents();
    61       }
    6257    }
    6358
     
    6964      parent = null;
    7065      variables = new VariableCollection();
    71       SubScopes = new ScopeList();
     66      subScopes = new ScopeList();
     67      Initialize();
    7268    }
    7369    /// <summary>
     
    7975      parent = null;
    8076      variables = new VariableCollection();
    81       SubScopes = new ScopeList();
     77      subScopes = new ScopeList();
     78      Initialize();
    8279    }
    8380    public Scope(string name, string description)
     
    8582      parent = null;
    8683      variables = new VariableCollection();
    87       SubScopes = new ScopeList();
     84      subScopes = new ScopeList();
     85      Initialize();
     86    }
     87    [StorableConstructor]
     88    private Scope(bool deserializing) : base(deserializing) { }
     89
     90    [StorableHook(HookType.AfterDeserialization)]
     91    private void Initialize() {
     92      RegisterSubScopesEvents();
    8893    }
    8994
     
    98103      Scope clone = new Scope();
    99104      cloner.RegisterClonedObject(this, clone);
    100       clone.Name = Name;
    101       clone.Description = Description;
     105      clone.ReadOnlyView = ReadOnlyView;
     106      clone.name = name;
     107      clone.description = description;
    102108      if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables);
    103109      if (subScopes.Count > 0) {
    104         clone.SubScopes = (ScopeList)cloner.Clone(subScopes);
     110        clone.subScopes = (ScopeList)cloner.Clone(subScopes);
    105111        foreach (IScope child in clone.SubScopes)
    106112          child.Parent = clone;
     113        clone.Initialize();
    107114      }
    108115      return clone;
     
    116123        subScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
    117124        subScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    118       }
    119     }
    120     private void DeregisterSubScopesEvents() {
    121       if (subScopes != null) {
    122         subScopes.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);
    123         subScopes.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);
    124         subScopes.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
    125         subScopes.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    126125      }
    127126    }
  • trunk/sources/HeuristicLab.Core/3.3/ScopeList.cs

    r3160 r3317  
    3333
    3434    public override IDeepCloneable Clone(Cloner cloner) {
    35       ScopeList clone = new ScopeList(this.Select(x => (IScope)cloner.Clone(x)));
     35      ScopeList clone = new ScopeList();
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
     38      clone.list = new List<IScope>(this.Select(x => (IScope)cloner.Clone(x)));
    3739      return clone;
    3840    }
  • trunk/sources/HeuristicLab.Core/3.3/Variable.cs

    r3160 r3317  
    3131  [StorableClass]
    3232  public sealed class Variable : NamedItem, IVariable {
     33    [Storable]
    3334    private IItem value;
    3435    /// <inheritdoc/>
    3536    /// <remarks>Calls <see cref="OnValueChanged"/> in the setter.</remarks>
    36     [Storable]
    3737    public IItem Value {
    3838      get { return value; }
     
    7272      : base(name) {
    7373      this.value = value;
    74       if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     74      Initialize();
    7575    }
    7676    public Variable(string name, string description, IItem value)
    7777      : base(name, description) {
    7878      this.value = value;
    79       if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     79      Initialize();
     80    }
     81    [StorableConstructor]
     82    private Variable(bool deserializing) : base(deserializing) { }
     83
     84    [StorableHook(HookType.AfterDeserialization)]
     85    private void Initialize() {
     86      if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    8087    }
    8188
     
    8693    /// <returns>The cloned object as <see cref="Variable"/>.</returns>
    8794    public override IDeepCloneable Clone(Cloner cloner) {
    88       Variable clone = new Variable(Name, Description, (IItem)cloner.Clone(value));
     95      Variable clone = new Variable(Name, Description);
    8996      cloner.RegisterClonedObject(this, clone);
     97      clone.ReadOnlyView = ReadOnlyView;
     98      clone.value = (IItem)cloner.Clone(value);
     99      clone.Initialize();
    90100      return clone;
    91101    }
  • trunk/sources/HeuristicLab.Core/3.3/VariableCollection.cs

    r3160 r3317  
    3333
    3434    public override IDeepCloneable Clone(Cloner cloner) {
    35       VariableCollection clone = new VariableCollection(this.Select(x => (IVariable)cloner.Clone(x)));
     35      VariableCollection clone = new VariableCollection();
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
     38      foreach (string key in dict.Keys)
     39        clone.dict.Add(key, (IVariable)cloner.Clone(dict[key]));
     40      clone.Initialize();
    3741      return clone;
    3842    }
  • trunk/sources/HeuristicLab.Data.Views/3.3/BoolValueView.cs

    r3048 r3317  
    6262        Caption = Content.ToString() + " (" + Content.GetType().Name + ")";
    6363        valueCheckBox.Checked = Content.Value;
    64         valueCheckBox.Enabled = true;
     64        valueCheckBox.Enabled = !Content.ReadOnlyView;
    6565      }
    6666    }
  • trunk/sources/HeuristicLab.Data.Views/3.3/ComparisonView.cs

    r3048 r3317  
    6262        Caption = Content.ToString() + " (" + Content.GetType().Name + ")";
    6363        valueComboBox.SelectedItem = Content.Value;
    64         valueComboBox.Enabled = true;
     64        valueComboBox.Enabled = !Content.ReadOnlyView;
    6565      }
    6666    }
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs

    r3228 r3317  
    9090        dataGridView.Columns[0].Width = dataGridView.Columns[0].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
    9191      }
     92      dataGridView.ReadOnly = Content.ReadOnlyView;
    9293      dataGridView.Enabled = true;
    9394    }
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r3316 r3317  
    104104        UpdateColumnHeaders();
    105105      }
     106      dataGridView.ReadOnly = Content.ReadOnlyView;
    106107      dataGridView.Enabled = true;
    107108    }
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs

    r3228 r3317  
    6565        Caption = Content.GetValue() + " (" + Content.GetType().Name + ")";
    6666        valueTextBox.Text = Content.GetValue();
     67        valueTextBox.ReadOnly = Content.ReadOnlyView;
    6768        valueTextBox.Enabled = true;
    6869      }
  • trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs

    r3160 r3317  
    3535      BoolArray clone = new BoolArray(array);
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
    3738      return clone;
    3839    }
  • trunk/sources/HeuristicLab.Data/3.3/BoolMatrix.cs

    r3310 r3317  
    3939    public override IDeepCloneable Clone(Cloner cloner) {
    4040      BoolMatrix clone = new BoolMatrix(matrix);
     41      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4143      clone.ColumnNames = new List<string>(ColumnNames);
    4244      clone.RowNames = new List<string>(RowNames);
    43       cloner.RegisterClonedObject(this, clone);
    4445      return clone;
    4546    }
  • trunk/sources/HeuristicLab.Data/3.3/BoolValue.cs

    r3306 r3317  
    4040      BoolValue clone = new BoolValue(value);
    4141      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4243      return clone;
    4344    }
  • trunk/sources/HeuristicLab.Data/3.3/Comparison.cs

    r3306 r3317  
    3939      Comparison clone = new Comparison(value);
    4040      cloner.RegisterClonedObject(this, clone);
     41      clone.ReadOnlyView = ReadOnlyView;
    4142      return clone;
    4243    }
  • trunk/sources/HeuristicLab.Data/3.3/DateTimeValue.cs

    r3160 r3317  
    3434      DateTimeValue clone = new DateTimeValue(value);
    3535      cloner.RegisterClonedObject(this, clone);
     36      clone.ReadOnlyView = ReadOnlyView;
    3637      return clone;
    3738    }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs

    r3160 r3317  
    3535      DoubleArray clone = new DoubleArray(array);
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
    3738      return clone;
    3839    }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs

    r3310 r3317  
    3939    public override IDeepCloneable Clone(Cloner cloner) {
    4040      DoubleMatrix clone = new DoubleMatrix(matrix);
     41      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4143      clone.ColumnNames = new List<string>(ColumnNames);
    4244      clone.RowNames = new List<string>(RowNames);
    43       cloner.RegisterClonedObject(this, clone);
    4445      return clone;
    4546    }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs

    r3306 r3317  
    4040      DoubleValue clone = new DoubleValue(value);
    4141      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4243      return clone;
    4344    }
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleArray.cs

    r3048 r3317  
    2525namespace HeuristicLab.Data {
    2626  public interface IStringConvertibleArray {
     27    bool ReadOnlyView { get; set; }
    2728    int Length { get; set; }
    2829
     
    3132    bool SetValue(string value, int index);
    3233
     34    event EventHandler ReadOnlyViewChanged;
    3335    event EventHandler<EventArgs<int>> ItemChanged;
    3436    event EventHandler Reset;
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleMatrix.cs

    r3310 r3317  
    2626namespace HeuristicLab.Data {
    2727  public interface IStringConvertibleMatrix {
     28    bool ReadOnlyView { get; set; }
    2829    int Rows { get; set; }
    2930    int Columns { get; set; }
     
    3738    bool SetValue(string value, int rowIndex, int columnIndex);
    3839
     40    event EventHandler ReadOnlyViewChanged;
    3941    event EventHandler<EventArgs<int, int>> ItemChanged;
    4042    event EventHandler Reset;
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleValue.cs

    r3048 r3317  
    2424namespace HeuristicLab.Data {
    2525  public interface IStringConvertibleValue {
     26    bool ReadOnlyView { get; set; }
     27
    2628    bool Validate(string value, out string errorMessage);
    2729    string GetValue();
    2830    bool SetValue(string value);
    2931
     32    event EventHandler ReadOnlyViewChanged;
    3033    event EventHandler ValueChanged;
    3134  }
  • trunk/sources/HeuristicLab.Data/3.3/IntArray.cs

    r3160 r3317  
    3535      IntArray clone = new IntArray(array);
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
    3738      return clone;
    3839    }
  • trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs

    r3310 r3317  
    3939    public override IDeepCloneable Clone(Cloner cloner) {
    4040      IntMatrix clone = new IntMatrix(matrix);
     41      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4143      clone.ColumnNames = new List<string>(ColumnNames);
    4244      clone.RowNames = new List<string>(RowNames);
    43       cloner.RegisterClonedObject(this, clone);
    4445      return clone;
    4546    }
  • trunk/sources/HeuristicLab.Data/3.3/IntValue.cs

    r3306 r3317  
    4040      IntValue clone = new IntValue(value);
    4141      cloner.RegisterClonedObject(this, clone);
     42      clone.ReadOnlyView = ReadOnlyView;
    4243      return clone;
    4344    }
  • trunk/sources/HeuristicLab.Data/3.3/PercentValue.cs

    r3160 r3317  
    3434      PercentValue clone = new PercentValue(value);
    3535      cloner.RegisterClonedObject(this, clone);
     36      clone.ReadOnlyView = ReadOnlyView;
    3637      return clone;
    3738    }
  • trunk/sources/HeuristicLab.Data/3.3/StringArray.cs

    r3306 r3317  
    8080      StringArray clone = new StringArray();
    8181      cloner.RegisterClonedObject(this, clone);
     82      clone.ReadOnlyView = ReadOnlyView;
    8283      clone.array = (string[])array.Clone();
    8384      return clone;
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs

    r3310 r3317  
    147147      StringMatrix clone = new StringMatrix();
    148148      cloner.RegisterClonedObject(this, clone);
     149      clone.ReadOnlyView = ReadOnlyView;
    149150      clone.matrix = (string[,])matrix.Clone();
    150151      clone.columnNames = new List<string>(columnNames);
  • trunk/sources/HeuristicLab.Data/3.3/StringValue.cs

    r3306 r3317  
    5757      StringValue clone = new StringValue(value);
    5858      cloner.RegisterClonedObject(this, clone);
     59      clone.ReadOnlyView = ReadOnlyView;
    5960      return clone;
    6061    }
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs

    r3160 r3317  
    3535      TimeSpanValue clone = new TimeSpanValue(value);
    3636      cloner.RegisterClonedObject(this, clone);
     37      clone.ReadOnlyView = ReadOnlyView;
    3738      return clone;
    3839    }
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVector.cs

    r3160 r3317  
    4444      BinaryVector clone = new BinaryVector(array);
    4545      cloner.RegisterClonedObject(this, clone);
     46      clone.ReadOnlyView = ReadOnlyView;
    4647      return clone;
    4748    }
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Tests/TestRandom.cs

    r3306 r3317  
    112112    }
    113113
     114    public bool ReadOnlyView {
     115      get { throw new NotImplementedException(); }
     116      set { throw new NotImplementedException(); }
     117    }
     118
    114119    public event EventHandler ItemImageChanged;
     120    public event EventHandler ReadOnlyViewChanged;
    115121    public event EventHandler ToStringChanged;
    116122
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs

    r3160 r3317  
    4444      IntegerVector clone = new IntegerVector(array);
    4545      cloner.RegisterClonedObject(this, clone);
     46      clone.ReadOnlyView = ReadOnlyView;
    4647      return clone;
    4748    }
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Tests/TestRandom.cs

    r3306 r3317  
    112112    }
    113113
     114    public bool ReadOnlyView {
     115      get { throw new NotImplementedException(); }
     116      set { throw new NotImplementedException(); }
     117    }
     118
    114119    public event EventHandler ItemImageChanged;
     120    public event EventHandler ReadOnlyViewChanged;
    115121    public event EventHandler ToStringChanged;
    116122
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs

    r3231 r3317  
    6565      Permutation clone = new Permutation(permutationType, array);
    6666      cloner.RegisterClonedObject(this, clone);
     67      clone.ReadOnlyView = ReadOnlyView;
    6768      return clone;
    6869    }
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationType.cs

    r3231 r3317  
    3434      PermutationType clone = new PermutationType(value);
    3535      cloner.RegisterClonedObject(this, clone);
     36      clone.ReadOnlyView = ReadOnlyView;
    3637      return clone;
    3738    }
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/Random.cs

    r3306 r3317  
    112112    }
    113113
     114    public bool ReadOnlyView {
     115      get { throw new NotImplementedException(); }
     116      set { throw new NotImplementedException(); }
     117    }
     118
    114119    public event EventHandler ItemImageChanged;
     120    public event EventHandler ReadOnlyViewChanged;
    115121    public event EventHandler ToStringChanged;
    116122
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVector.cs

    r3160 r3317  
    4444      RealVector clone = new RealVector(array);
    4545      cloner.RegisterClonedObject(this, clone);
     46      clone.ReadOnlyView = ReadOnlyView;
    4647      return clone;
    4748    }
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/TestRandom.cs

    r3306 r3317  
    112112    }
    113113
     114    public bool ReadOnlyView {
     115      get { throw new NotImplementedException(); }
     116      set { throw new NotImplementedException(); }
     117    }
     118
    114119    public event EventHandler ItemImageChanged;
     120    public event EventHandler ReadOnlyViewChanged;
    115121    public event EventHandler ToStringChanged;
    116122
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTree.cs

    r3294 r3317  
    9999      SymbolicExpressionTree clone = new SymbolicExpressionTree();
    100100      cloner.RegisterClonedObject(this, clone);
     101      clone.ReadOnlyView = ReadOnlyView;
    101102      clone.root = (SymbolicExpressionTreeNode)this.root.Clone();
    102103      clone.allowedFunctionsInBranch = new Dictionary<int, IEnumerable<string>>(allowedFunctionsInBranch);
  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs

    r3303 r3317  
    418418    public override IDeepCloneable Clone(Cloner cloner) {
    419419      ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);
    420       clone.Description = Description;
     420      clone.description = description;
    421421      clone.code = Code;
    422422      clone.executeMethod = executeMethod;
  • trunk/sources/HeuristicLab.Operators/3.3/MultipleCallsOperator.cs

    r3212 r3317  
    3737    private List<IValueParameter<IOperator>> operatorParameters;
    3838
     39    [Storable]
    3940    private OperatorList operators;
    40     [Storable]
    4141    public OperatorList Operators {
    4242      get { return operators; }
    43       private set {
    44         if (operators != null) DeregisterOperatorsEvents();
    45         operators = value;
    46         if (operators != null) RegisterOperatorsEvents();
    47       }
    4843    }
    4944
    5045    public MultipleCallsOperator()
    5146      : base() {
    52       Operators = new OperatorList();
     47      operators = new OperatorList();
    5348      Initialize();
    5449    }
     50    [StorableConstructor]
     51    protected MultipleCallsOperator(bool deserializing) : base(deserializing) { }
    5552
    5653    [StorableHook(HookType.AfterDeserialization)]
    5754    private void Initialize() {
     55      if (operators != null) RegisterOperatorsEvents();
    5856      operatorParameters = new List<IValueParameter<IOperator>>();
    5957      for (int i = 0; i < Operators.Count; i++) {
     
    6664    public override IDeepCloneable Clone(Cloner cloner) {
    6765      MultipleCallsOperator clone = (MultipleCallsOperator)base.Clone(cloner);
    68       clone.Operators = (OperatorList)cloner.Clone(operators);
     66      clone.operators = (OperatorList)cloner.Clone(operators);
    6967      clone.Initialize();
    7068      return clone;
  • trunk/sources/HeuristicLab.Operators/3.3/Operator.cs

    r3306 r3317  
    113113      breakpoint = false;
    114114    }
     115    [StorableConstructor]
     116    protected Operator(bool deserializing) : base(deserializing) { }
    115117
    116118    /// <summary>
  • trunk/sources/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs

    r3160 r3317  
    4343      Parameters.Add(new OperatorParameter("Successor", "Operator which is executed next."));
    4444    }
     45    [StorableConstructor]
     46    protected SingleSuccessorOperator(bool deserializing) : base(deserializing) { }
    4547
    4648    public override IOperation Apply() {
  • trunk/sources/HeuristicLab.Operators/3.3/ValuesCollector.cs

    r3160 r3317  
    3131  [StorableClass]
    3232  public abstract class ValuesCollector : SingleSuccessorOperator, IOperator {
     33    [Storable]
    3334    private ParameterCollection collectedValues;
    34     [Storable]
    3535    public ParameterCollection CollectedValues {
    3636      get { return collectedValues; }
    37       private set {
    38         collectedValues = value;
    39         collectedValues.ItemsAdded += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsAdded);
    40         collectedValues.ItemsRemoved += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsRemoved);
    41         collectedValues.CollectionReset += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_CollectionReset);
    42       }
    4337    }
    4438
    4539    public ValuesCollector()
    4640      : base() {
    47       CollectedValues = new ParameterCollection();
     41      collectedValues = new ParameterCollection();
     42      Initialize();
     43    }
     44    [StorableConstructor]
     45    protected ValuesCollector(bool deserializing) : base(deserializing) { }
     46
     47    [StorableHook(HookType.AfterDeserialization)]
     48    private void Initialize() {
     49      collectedValues.ItemsAdded += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsAdded);
     50      collectedValues.ItemsRemoved += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsRemoved);
     51      collectedValues.CollectionReset += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_CollectionReset);
    4852    }
    4953
    5054    public override IDeepCloneable Clone(Cloner cloner) {
    5155      ValuesCollector clone = (ValuesCollector)base.Clone(cloner);
    52       clone.CollectedValues = (ParameterCollection)cloner.Clone(collectedValues);
     56      clone.collectedValues = (ParameterCollection)cloner.Clone(collectedValues);
     57      clone.Initialize();
    5358      return clone;
    5459    }
  • trunk/sources/HeuristicLab.Optimization/3.3/OptimizerList.cs

    r3274 r3317  
    3333    public OptimizerList(int capacity) : base(capacity) { }
    3434    public OptimizerList(IEnumerable<IOptimizer> collection) : base(collection) { }
    35 
    36     public override IDeepCloneable Clone(Cloner cloner) {
    37       OptimizerList clone = new OptimizerList(this.Select(x => (IOptimizer)cloner.Clone(x)));
    38       cloner.RegisterClonedObject(this, clone);
    39       return clone;
    40     }
    4135  }
    4236}
  • trunk/sources/HeuristicLab.Optimization/3.3/Result.cs

    r3226 r3317  
    4545    }
    4646
     47    [Storable]
    4748    private IItem value;
    48     [Storable]
    4949    public IItem Value {
    5050      get { return value; }
     
    8484      this.dataType = value == null ? typeof(IItem) : value.GetType();
    8585      this.value = value;
    86       if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     86      Initialize();
    8787    }
    8888    public Result(string name, string description, IItem value)
     
    9090      this.dataType = value == null ? typeof(IItem) : value.GetType();
    9191      this.value = value;
    92       if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     92      Initialize();
     93    }
     94    [StorableConstructor]
     95    private Result(bool deserializing) : base(deserializing) { }
     96
     97    [StorableHook(HookType.AfterDeserialization)]
     98    private void Initialize() {
     99      if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    93100    }
    94101
    95102    public override IDeepCloneable Clone(Cloner cloner) {
    96       Result clone = new Result(Name, Description, (IItem)cloner.Clone(value));
     103      Result clone = new Result(Name, Description, DataType);
    97104      cloner.RegisterClonedObject(this, clone);
    98       clone.dataType = dataType;
     105      clone.ReadOnlyView = ReadOnlyView;
     106      clone.value = (IItem)cloner.Clone(value);
     107      clone.Initialize();
    99108      return clone;
    100109    }
  • trunk/sources/HeuristicLab.Optimization/3.3/ResultCollection.cs

    r3274 r3317  
    3232    public ResultCollection(int capacity) : base(capacity) { }
    3333    public ResultCollection(IEnumerable<IResult> collection) : base(collection) { }
    34 
    35     public override IDeepCloneable Clone(Cloner cloner) {
    36       ResultCollection clone = new ResultCollection(this.Select(x => (IResult)cloner.Clone(x)));
    37       cloner.RegisterClonedObject(this, clone);
    38       return clone;
    39     }
    4034  }
    4135}
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r3280 r3317  
    3232    public RunCollection(int capacity) : base(capacity) { }
    3333    public RunCollection(IEnumerable<IRun> collection) : base(collection) { }
    34 
    35     public override IDeepCloneable Clone(Cloner cloner) {
    36       RunCollection clone = new RunCollection(this.Select(x => (IRun)cloner.Clone(x)));
    37       cloner.RegisterClonedObject(this, clone);
    38       return clone;
    39     }
    4034  }
    4135}
  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r3136 r3317  
    7171      this.actualName = actualName == null ? string.Empty : actualName;
    7272    }
     73    [StorableConstructor]
     74    protected LookupParameter(bool deserializing) : base(deserializing) { }
    7375
    7476    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r3136 r3317  
    3333  [StorableClass]
    3434  public class OptionalConstrainedValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem {
     35    [Storable]
    3536    private ItemSet<T> validValues;
    36     [Storable]
    3737    public ItemSet<T> ValidValues {
    3838      get { return validValues; }
    39       private set {
    40         DeregisterValidValuesEvents();
    41         validValues = value;
    42         RegisterValidValuesEvents();
    43       }
    4439    }
    4540
     41    [Storable]
    4642    private T value;
    47     [Storable]
    4843    public virtual T Value {
    4944      get { return this.value; }
     
    7469    public OptionalConstrainedValueParameter()
    7570      : base("Anonymous", typeof(T)) {
    76       ValidValues = new ItemSet<T>();
     71      this.validValues = new ItemSet<T>();
     72      Initialize();
    7773    }
    7874    public OptionalConstrainedValueParameter(string name)
    7975      : base(name, typeof(T)) {
    80       ValidValues = new ItemSet<T>();
     76      this.validValues = new ItemSet<T>();
     77      Initialize();
    8178    }
    8279    public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues)
    8380      : base(name, typeof(T)) {
    84       ValidValues = validValues;
     81      this.validValues = validValues;
     82      Initialize();
    8583    }
    8684    public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues, T value)
    8785      : base(name, typeof(T)) {
    88       ValidValues = validValues;
    89       Value = value;
     86      this.validValues = validValues;
     87      this.value = value;
     88      Initialize();
    9089    }
    9190    public OptionalConstrainedValueParameter(string name, string description)
    9291      : base(name, description, typeof(T)) {
    93       ValidValues = new ItemSet<T>();
     92      this.validValues = new ItemSet<T>();
     93      Initialize();
    9494    }
    9595    public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues)
    9696      : base(name, description, typeof(T)) {
    97       ValidValues = validValues;
     97      this.validValues = validValues;
     98      Initialize();
    9899    }
    99100    public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value)
    100101      : base(name, description, typeof(T)) {
    101       ValidValues = validValues;
    102       Value = value;
     102      this.validValues = validValues;
     103      this.value = value;
     104      Initialize();
     105    }
     106    [StorableConstructor]
     107    protected OptionalConstrainedValueParameter(bool deserializing) : base(deserializing) { }
     108
     109    [StorableHook(HookType.AfterDeserialization)]
     110    private void Initialize() {
     111      RegisterValidValuesEvents();
     112      if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    103113    }
    104114
    105115    public override IDeepCloneable Clone(Cloner cloner) {
    106116      OptionalConstrainedValueParameter<T> clone = (OptionalConstrainedValueParameter<T>)base.Clone(cloner);
    107       clone.ValidValues = (ItemSet<T>)cloner.Clone(validValues);
    108       clone.Value = (T)cloner.Clone(value);
     117      clone.validValues = (ItemSet<T>)cloner.Clone(validValues);
     118      clone.value = (T)cloner.Clone(value);
     119      clone.Initialize();
    109120      return clone;
    110121    }
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r3136 r3317  
    3232  [StorableClass]
    3333  public class OptionalValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem {
     34    [Storable]
    3435    private T value;
    35     [Storable]
    3636    public virtual T Value {
    3737      get { return this.value; }
     
    6666    public OptionalValueParameter(string name, T value)
    6767      : base(name, typeof(T)) {
    68       Value = value;
     68      this.value = value;
     69      Initialize();
    6970    }
    7071    public OptionalValueParameter(string name, string description)
     
    7374    public OptionalValueParameter(string name, string description, T value)
    7475      : base(name, description, typeof(T)) {
    75       Value = value;
     76      this.value = value;
     77      Initialize();
     78    }
     79    [StorableConstructor]
     80    protected OptionalValueParameter(bool deserializing) : base(deserializing) { }
     81
     82    [StorableHook(HookType.AfterDeserialization)]
     83    private void Initialize() {
     84      if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    7685    }
    7786
    7887    public override IDeepCloneable Clone(Cloner cloner) {
    7988      OptionalValueParameter<T> clone = (OptionalValueParameter<T>)base.Clone(cloner);
    80       clone.Value = (T)cloner.Clone(value);
     89      clone.value = (T)cloner.Clone(value);
     90      clone.Initialize();
    8191      return clone;
    8292    }
  • trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs

    r3136 r3317  
    9191      this.dataType = dataType;
    9292    }
     93    [StorableConstructor]
     94    protected Parameter(bool deserializing) : base(deserializing) { }
    9395
    9496    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r3080 r3317  
    3232  [StorableClass]
    3333  public class ValueLookupParameter<T> : LookupParameter<T>, IValueLookupParameter<T> where T : class, IItem {
     34    [Storable]
    3435    private T value;
    35     [Storable]
    3636    public T Value {
    3737      get { return this.value; }
     
    6666    public ValueLookupParameter(string name, T value)
    6767      : base(name) {
    68       Value = value;
     68      this.value = value;
     69      Initialize();
    6970    }
    7071    public ValueLookupParameter(string name, string description)
     
    7374    public ValueLookupParameter(string name, string description, T value)
    7475      : base(name, description) {
    75       Value = value;
     76      this.value = value;
     77      Initialize();
    7678    }
    7779    public ValueLookupParameter(string name, string description, string actualName)
    7880      : base(name, description, actualName) {
    7981    }
     82    [StorableConstructor]
     83    protected ValueLookupParameter(bool deserializing) : base(deserializing) { }
     84
     85    [StorableHook(HookType.AfterDeserialization)]
     86    private void Initialize() {
     87      if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     88    }
    8089
    8190    public override IDeepCloneable Clone(Cloner cloner) {
    8291      ValueLookupParameter<T> clone = (ValueLookupParameter<T>)base.Clone(cloner);
    83       clone.Value = (T)cloner.Clone(value);
     92      clone.value = (T)cloner.Clone(value);
     93      clone.Initialize();
    8494      return clone;
    8595    }
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/AntTrail.cs

    r3239 r3317  
    3434  [StorableClass]
    3535  public sealed class AntTrail : Item {
     36    [Storable]
    3637    private SymbolicExpressionTree expression;
    37     [Storable]
    3838    public SymbolicExpressionTree SymbolicExpressionTree {
    3939      get { return expression; }
     
    4848    }
    4949
     50    [Storable]
    5051    private BoolMatrix world;
    51     [Storable]
    5252    public BoolMatrix World {
    5353      get { return world; }
     
    6161      }
    6262    }
     63    [Storable]
    6364    private IntValue maxTimeSteps;
    64     [Storable]
    6565    public IntValue MaxTimeSteps {
    6666      get { return maxTimeSteps; }
     
    8080    public AntTrail(BoolMatrix world, SymbolicExpressionTree expression, IntValue maxTimeSteps)
    8181      : this() {
    82       World = world;
    83       SymbolicExpressionTree = expression;
    84       MaxTimeSteps = maxTimeSteps;
     82      this.world = world;
     83      this.expression = expression;
     84      this.maxTimeSteps = maxTimeSteps;
     85      Initialize();
     86    }
     87    [StorableConstructor]
     88    private AntTrail(bool deserializing) : base(deserializing) { }
     89
     90    [StorableHook(HookType.AfterDeserialization)]
     91    private void Initialize() {
     92      //if (expression != null) RegisterSymbolicExpressionTreeEvents();
     93      if (world != null) RegisterWorldEvents();
     94      if (maxTimeSteps != null) RegisterMaxTimeStepsEvents();
    8595    }
    8696
     
    8898      AntTrail clone = new AntTrail();
    8999      cloner.RegisterClonedObject(this, clone);
     100      clone.ReadOnlyView = ReadOnlyView;
    90101      clone.expression = (SymbolicExpressionTree)cloner.Clone(expression);
    91102      clone.world = (BoolMatrix)cloner.Clone(world);
    92103      clone.maxTimeSteps = (IntValue)cloner.Clone(maxTimeSteps);
     104      clone.Initialize();
    93105      return clone;
    94106    }
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/PathTSPTour.cs

    r3306 r3317  
    3939    }
    4040
     41    [Storable]
    4142    private DoubleMatrix coordinates;
    42     [Storable]
    4343    public DoubleMatrix Coordinates {
    4444      get { return coordinates; }
     
    5252      }
    5353    }
     54    [Storable]
    5455    private Permutation permutation;
    55     [Storable]
    5656    public Permutation Permutation {
    5757      get { return permutation; }
     
    6969    public PathTSPTour(DoubleMatrix coordinates)
    7070      : base() {
    71       Coordinates = coordinates;
     71      this.coordinates = coordinates;
     72      Initialize();
    7273    }
    7374    public PathTSPTour(DoubleMatrix coordinates, Permutation permutation)
    74       : this(coordinates) {
    75       Permutation = permutation;
     75      : base() {
     76      this.coordinates = coordinates;
     77      this.permutation = permutation;
     78      Initialize();
     79    }
     80    [StorableConstructor]
     81    private PathTSPTour(bool deserializing) : base(deserializing) { }
     82
     83    [StorableHook(HookType.AfterDeserialization)]
     84    private void Initialize() {
     85      if (coordinates != null) RegisterCoordinatesEvents();
     86      if (permutation != null) RegisterPermutationEvents();
    7687    }
    7788
     
    7990      PathTSPTour clone = new PathTSPTour();
    8091      cloner.RegisterClonedObject(this, clone);
    81       clone.Coordinates = (DoubleMatrix)cloner.Clone(coordinates);
    82       clone.Permutation = (Permutation)cloner.Clone(permutation);
     92      clone.ReadOnlyView = ReadOnlyView;
     93      clone.coordinates = (DoubleMatrix)cloner.Clone(coordinates);
     94      clone.permutation = (Permutation)cloner.Clone(permutation);
     95      clone.Initialize();
    8396      return clone;
    8497    }
  • trunk/sources/HeuristicLab.Random/3.3/MersenneTwister.cs

    r3017 r3317  
    8484    /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns>
    8585    public override IDeepCloneable Clone(Cloner cloner) {
    86       MersenneTwister clone = new MersenneTwister();
    87       cloner.RegisterClonedObject(this, clone);
     86      MersenneTwister clone = (MersenneTwister)base.Clone(cloner);
    8887      clone.state = (uint[])state.Clone();
    8988      clone.p = p;
  • trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs

    r3017 r3317  
    553553    /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns>
    554554    public override IDeepCloneable Clone(Cloner cloner) {
    555       NormalDistributedRandom clone = new NormalDistributedRandom((IRandom)cloner.Clone(uniform), mu, sigma);
    556       cloner.RegisterClonedObject(this, clone);
     555      NormalDistributedRandom clone = (NormalDistributedRandom)base.Clone(cloner);
     556      clone.uniform = (IRandom)cloner.Clone(uniform);
     557      clone.mu = mu;
     558      clone.sigma = sigma;
    557559      return clone;
    558560    }
Note: See TracChangeset for help on using the changeset viewer.