Changeset 3390


Ignore:
Timestamp:
04/18/10 02:27:02 (12 years ago)
Author:
swagner
Message:

Refactored HeuristicLab.Collections (#977)

Location:
trunk/sources
Files:
15 added
16 edited
13 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Collections/3.3/HeuristicLab.Collections-3.3.csproj

    r3384 r3390  
    122122  </ItemGroup>
    123123  <ItemGroup>
    124     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    125       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    126       <Name>HeuristicLab.Common-3.3</Name>
    127     </ProjectReference>
    128     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    129       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    130       <Name>HeuristicLab.Persistence-3.3</Name>
    131     </ProjectReference>
    132124    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    133125      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • trunk/sources/HeuristicLab.Collections/3.3/IObservableArray.cs

    r3368 r3390  
    2323using System.Collections.Generic;
    2424using System.ComponentModel;
    25 using HeuristicLab.Common;
    2625
    2726namespace HeuristicLab.Collections {
    28   public interface IObservableArray<T> : IList<T>, INotifyObservableArrayItemsChanged<T>, INotifyPropertyChanged, IContent {
     27  public interface IObservableArray<T> : IList<T>, INotifyObservableArrayItemsChanged<T>, INotifyPropertyChanged {
    2928    int Length { get; }
    3029  }
  • trunk/sources/HeuristicLab.Collections/3.3/IObservableCollection.cs

    r3368 r3390  
    2323using System.Collections.Generic;
    2424using System.ComponentModel;
    25 using HeuristicLab.Common;
    2625
    2726namespace HeuristicLab.Collections {
    28   public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged, IContent { }
     27  public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged { }
    2928}
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableArray.cs

    r3370 r3390  
    2525using System.ComponentModel;
    2626using System.Linq;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    2928namespace HeuristicLab.Collections {
    3029  [Serializable]
    31   [StorableClass]
    3230  public class ObservableArray<T> : IObservableArray<T> {
    33     [Storable]
    3431    protected T[] array;
    3532
    3633    #region Properties
    37     [Storable]
    38     private bool readOnlyView;
    39     public virtual bool ReadOnlyView {
    40       get { return readOnlyView; }
    41       set {
    42         if ((readOnlyView != value) && !array.IsReadOnly) {
    43           readOnlyView = value;
    44           OnReadOnlyViewChanged();
    45           OnPropertyChanged("ReadOnlyView");
    46         }
    47       }
    48     }
    49 
    5034    public int Length {
    5135      get { return array.Length; }
     
    7660    public ObservableArray() {
    7761      array = new T[0];
    78       readOnlyView = array.IsReadOnly;
    7962    }
    8063    public ObservableArray(int length) {
    8164      array = new T[length];
    82       readOnlyView = array.IsReadOnly;
    8365    }
    8466    public ObservableArray(T[] array) {
    8567      this.array = (T[])array.Clone();
    86       readOnlyView = array.IsReadOnly;
    8768    }
    8869    public ObservableArray(IEnumerable<T> collection) {
    8970      array = collection.ToArray();
    90       readOnlyView = array.IsReadOnly;
    9171    }
    9272    #endregion
     
    297277
    298278    #region Events
    299     [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 
    306279    [field: NonSerialized]
    307280    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced;
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableCollection.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726
    2827namespace HeuristicLab.Collections {
    2928  [Serializable]
    30   [StorableClass]
    3129  public class ObservableCollection<T> : IObservableCollection<T> {
    32     [Storable]
    3330    protected List<T> list;
    3431
    3532    #region Properties
    36     [Storable]
    37     private bool readOnlyView;
    38     public virtual bool ReadOnlyView {
    39       get { return readOnlyView; }
    40       set {
    41         if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) {
    42           readOnlyView = value;
    43           OnReadOnlyViewChanged();
    44           OnPropertyChanged("ReadOnlyView");
    45         }
    46       }
    47     }
    48 
    4933    public int Capacity {
    5034      get { return list.Capacity; }
     
    6751    public ObservableCollection() {
    6852      list = new List<T>();
    69       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7053    }
    7154    public ObservableCollection(int capacity) {
    7255      list = new List<T>(capacity);
    73       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7456    }
    7557    public ObservableCollection(IEnumerable<T> collection) {
    7658      list = new List<T>(collection);
    77       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    7859    }
    7960    #endregion
     
    205186    #region Events
    206187    [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]
    214188    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    215189    protected virtual void OnItemsAdded(IEnumerable<T> items) {
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableDictionary.cs

    r3370 r3390  
    2525using System.ComponentModel;
    2626using System.Linq;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    2928namespace HeuristicLab.Collections {
    3029  [Serializable]
    31   [StorableClass]
    3230  public class ObservableDictionary<TKey, TValue> : IObservableDictionary<TKey, TValue> {
    33     [Storable]
    34     private Dictionary<TKey, TValue> dict;
     31    protected Dictionary<TKey, TValue> dict;
    3532
    3633    #region Properties
    37     [Storable]
    38     private bool readOnlyView;
    39     public virtual bool ReadOnlyView {
    40       get { return readOnlyView; }
    41       set {
    42         if ((readOnlyView != value) && !((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly) {
    43           readOnlyView = value;
    44           OnReadOnlyViewChanged();
    45           OnPropertyChanged("ReadOnlyView");
    46         }
    47       }
    48     }
    49 
    5034    public ICollection<TKey> Keys {
    5135      get { return dict.Keys; }
     
    8468    public ObservableDictionary() {
    8569      dict = new Dictionary<TKey, TValue>();
    86       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    8770    }
    8871    public ObservableDictionary(int capacity) {
    8972      dict = new Dictionary<TKey, TValue>(capacity);
    90       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    9173    }
    9274    public ObservableDictionary(IEqualityComparer<TKey> comparer) {
    9375      dict = new Dictionary<TKey, TValue>(comparer);
    94       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    9576    }
    9677    public ObservableDictionary(IDictionary<TKey, TValue> dictionary) {
    9778      dict = new Dictionary<TKey, TValue>(dictionary);
    98       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    9979    }
    10080    public ObservableDictionary(int capacity, IEqualityComparer<TKey> comparer) {
    10181      dict = new Dictionary<TKey, TValue>(capacity, comparer);
    102       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    10382    }
    10483    public ObservableDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer) {
    10584      dict = new Dictionary<TKey, TValue>(dictionary, comparer);
    106       readOnlyView = ((ICollection<KeyValuePair<TKey, TValue>>)dict).IsReadOnly;
    10785    }
    10886    #endregion
     
    200178    #region Events
    201179    [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]
    209180    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsAdded;
    210181    protected virtual void OnItemsAdded(IEnumerable<KeyValuePair<TKey, TValue>> items) {
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableKeyedCollection.cs

    r3370 r3390  
    2525using System.ComponentModel;
    2626using System.Linq;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    2928namespace HeuristicLab.Collections {
    3029  [Serializable]
    31   [StorableClass]
    3230  public abstract class ObservableKeyedCollection<TKey, TItem> : IObservableKeyedCollection<TKey, TItem> {
    33     [Storable]
    3431    protected Dictionary<TKey, TItem> dict;
    3532
    3633    #region Properties
    37     [Storable]
    38     private bool readOnlyView;
    39     public virtual bool ReadOnlyView {
    40       get { return readOnlyView; }
    41       set {
    42         if ((readOnlyView != value) && !((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly) {
    43           readOnlyView = value;
    44           OnReadOnlyViewChanged();
    45           OnPropertyChanged("ReadOnlyView");
    46         }
    47       }
    48     }
    49 
    5034    public int Count {
    5135      get { return dict.Count; }
     
    6852    protected ObservableKeyedCollection() {
    6953      dict = new Dictionary<TKey, TItem>();
    70       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    7154    }
    7255    protected ObservableKeyedCollection(int capacity) {
    7356      dict = new Dictionary<TKey, TItem>(capacity);
    74       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    7557    }
    7658    protected ObservableKeyedCollection(IEqualityComparer<TKey> comparer) {
    7759      dict = new Dictionary<TKey, TItem>(comparer);
    78       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    7960    }
    8061    protected ObservableKeyedCollection(IEnumerable<TItem> collection) {
     
    8364      foreach (TItem item in collection)
    8465        dict.Add(GetKeyForItem(item), item);
    85       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    8666    }
    8767    protected ObservableKeyedCollection(int capacity, IEqualityComparer<TKey> comparer) {
    8868      dict = new Dictionary<TKey, TItem>(capacity, comparer);
    89       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    9069    }
    9170    protected ObservableKeyedCollection(IEnumerable<TItem> collection, IEqualityComparer<TKey> comparer) {
     
    9473      foreach (TItem item in collection)
    9574        dict.Add(GetKeyForItem(item), item);
    96       readOnlyView = ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly;
    9775    }
    9876    #endregion
     
    269247    #region Events
    270248    [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]
    278249    public event CollectionItemsChangedEventHandler<TItem> ItemsAdded;
    279250    protected virtual void OnItemsAdded(IEnumerable<TItem> items) {
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726
    2827namespace HeuristicLab.Collections {
    2928  [Serializable]
    30   [StorableClass]
    3129  public class ObservableList<T> : IObservableList<T> {
    32     [Storable]
    3330    protected List<T> list;
    3431
    3532    #region Properties
    36     [Storable]
    37     private bool readOnlyView;
    38     public virtual bool ReadOnlyView {
    39       get { return readOnlyView; }
    40       set {
    41         if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) {
    42           readOnlyView = value;
    43           OnReadOnlyViewChanged();
    44           OnPropertyChanged("ReadOnlyView");
    45         }
    46       }
    47     }
    48 
    4933    public int Capacity {
    5034      get { return list.Capacity; }
     
    8165    public ObservableList() {
    8266      list = new List<T>();
    83       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    8467    }
    8568    public ObservableList(int capacity) {
    8669      list = new List<T>(capacity);
    87       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    8870    }
    8971    public ObservableList(IEnumerable<T> collection) {
    9072      list = new List<T>(collection);
    91       readOnlyView = ((ICollection<T>)list).IsReadOnly;
    9273    }
    9374    #endregion
     
    391372    #region Events
    392373    [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]
    400374    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded;
    401375    protected virtual void OnItemsAdded(IEnumerable<IndexedItem<T>> items) {
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableSet.cs

    r3370 r3390  
    2525using System.ComponentModel;
    2626using System.Linq;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    2928namespace HeuristicLab.Collections {
    3029  [Serializable]
    31   [StorableClass]
    3230  public class ObservableSet<T> : IObservableSet<T> {
    33     [Storable]
    3431    protected HashSet<T> set;
    3532
    3633    #region Properties
    37     [Storable]
    38     private bool readOnlyView;
    39     public virtual bool ReadOnlyView {
    40       get { return readOnlyView; }
    41       set {
    42         if ((readOnlyView != value) && !((ICollection<T>)set).IsReadOnly) {
    43           readOnlyView = value;
    44           OnReadOnlyViewChanged();
    45           OnPropertyChanged("ReadOnlyView");
    46         }
    47       }
    48     }
    49 
    5034    public IEqualityComparer<T> Comparer {
    5135      get { return set.Comparer; }
     
    6246    public ObservableSet() {
    6347      set = new HashSet<T>();
    64       readOnlyView = ((ICollection<T>)set).IsReadOnly;
    6548    }
    6649    public ObservableSet(IEnumerable<T> collection) {
    6750      set = new HashSet<T>(collection);
    68       readOnlyView = ((ICollection<T>)set).IsReadOnly;
    6951    }
    7052    public ObservableSet(IEqualityComparer<T> comparer) {
    7153      set = new HashSet<T>(comparer);
    72       readOnlyView = ((ICollection<T>)set).IsReadOnly;
    7354    }
    7455    public ObservableSet(IEnumerable<T> collection, IEqualityComparer<T> comparer) {
    7556      set = new HashSet<T>(collection, comparer);
    76       readOnlyView = ((ICollection<T>)set).IsReadOnly;
    7757    }
    7858    #endregion
     
    244224    #region Events
    245225    [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]
    253226    public event CollectionItemsChangedEventHandler<T> ItemsAdded;
    254227    protected virtual void OnItemsAdded(IEnumerable<T> items) {
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableArray.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using HeuristicLab.Common;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableArray<T> : IObservableArray<T> {
    33     [Storable]
    34     private IObservableArray<T> array;
     30    protected IObservableArray<T> array;
    3531
    3632    #region Properties
    37     public bool ReadOnlyView {
    38       get { return true; }
    39       set { }
    40     }
    41 
    4233    public int Length {
    4334      get { return array.Length; }
     
    115106
    116107    #region Events
    117     [StorableHook(HookType.AfterDeserialization)]
    118108    protected void RegisterEvents() {
    119109      array.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<T>>(array_ItemsReplaced);
     
    121111      array.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<T>>(array_CollectionReset);
    122112      array.PropertyChanged += new PropertyChangedEventHandler(array_PropertyChanged);
    123     }
    124 
    125     event EventHandler IContent.ReadOnlyViewChanged {
    126       add { }
    127       remove { }
    128113    }
    129114
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableCollection.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableCollection<T> : IObservableCollection<T> {
    33     [Storable]
    34     private IObservableCollection<T> collection;
     30    protected IObservableCollection<T> collection;
    3531
    3632    #region Properties
    37     public bool ReadOnlyView {
    38       get { return true; }
    39       set { }
    40     }
    41 
    4233    public int Count {
    4334      get { return collection.Count; }
     
    9384
    9485    #region Events
    95     [StorableHook(HookType.AfterDeserialization)]
    9686    protected void RegisterEvents() {
    9787      collection.ItemsAdded += new CollectionItemsChangedEventHandler<T>(collection_ItemsAdded);
     
    10191    }
    10292
    103     event EventHandler IContent.ReadOnlyViewChanged {
    104       add { }
    105       remove { }
    106     }
    10793
    10894    [field: NonSerialized]
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableDictionary.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableDictionary<TKey, TValue> : IObservableDictionary<TKey, TValue> {
    33     [Storable]
    34     private IObservableDictionary<TKey, TValue> dict;
     30    protected IObservableDictionary<TKey, TValue> dict;
    3531
    3632    #region Properties
    37     public bool ReadOnlyView {
    38       get { return true; }
    39       set { }
    40     }
    41 
    4233    public ICollection<TKey> Keys {
    4334      get { return dict.Keys; }
     
    120111
    121112    #region Events
    122     [StorableHook(HookType.AfterDeserialization)]
    123113    protected void RegisterEvents() {
    124114      dict.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>>(dict_ItemsAdded);
     
    127117      dict.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>>(dict_CollectionReset);
    128118      dict.PropertyChanged += new PropertyChangedEventHandler(dict_PropertyChanged);
    129     }
    130 
    131     event EventHandler IContent.ReadOnlyViewChanged {
    132       add { }
    133       remove { }
    134119    }
    135120
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableKeyedCollection.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableKeyedCollection<TKey, TItem> : IObservableKeyedCollection<TKey, TItem> {
    33     [Storable]
    34     private IObservableKeyedCollection<TKey, TItem> collection;
     30    protected IObservableKeyedCollection<TKey, TItem> collection;
    3531
    3632    #region Properties
    37     public virtual bool ReadOnlyView {
    38       get { return true; }
    39       set { throw new NotSupportedException(); }
    40     }
    41 
    4233    public int Count {
    4334      get { return collection.Count; }
     
    109100
    110101    #region Events
    111     [StorableHook(HookType.AfterDeserialization)]
    112102    protected void RegisterEvents() {
    113103      collection.ItemsAdded += new CollectionItemsChangedEventHandler<TItem>(collection_ItemsAdded);
     
    116106      collection.CollectionReset += new CollectionItemsChangedEventHandler<TItem>(collection_CollectionReset);
    117107      collection.PropertyChanged += new PropertyChangedEventHandler(collection_PropertyChanged);
    118     }
    119 
    120     event EventHandler IContent.ReadOnlyViewChanged {
    121       add { }
    122       remove { }
    123108    }
    124109
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableList.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableList<T> : IObservableList<T> {
    33     [Storable]
    34     private IObservableList<T> list;
     30    protected IObservableList<T> list;
    3531
    3632    #region Properties
    37     public bool ReadOnlyView {
    38       get { return true; }
    39       set { }
    40     }
    41 
    4233    public int Count {
    4334      get { return ((ICollection<T>)list).Count; }
     
    112103
    113104    #region Events
    114     [StorableHook(HookType.AfterDeserialization)]
    115105    protected void RegisterEvents() {
    116106      list.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<T>>(list_ItemsAdded);
     
    125115    }
    126116
    127     event EventHandler IContent.ReadOnlyViewChanged {
    128       add { }
    129       remove { }
    130     }
    131 
    132117    [field: NonSerialized]
    133118    public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded;
  • trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableSet.cs

    r3370 r3390  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
    26 using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Collections {
    3028  [Serializable]
    31   [StorableClass]
    3229  public class ReadOnlyObservableSet<T> : IObservableSet<T> {
    33     [Storable]
    34     private IObservableSet<T> set;
     30    protected IObservableSet<T> set;
    3531
    3632    #region Properties
    37     public bool ReadOnlyView {
    38       get { return true; }
    39       set { }
    40     }
    41 
    4233    public int Count {
    4334      get { return set.Count; }
     
    134125
    135126    #region Events
    136     [StorableHook(HookType.AfterDeserialization)]
    137127    protected void RegisterEvents() {
    138128      set.ItemsAdded += new CollectionItemsChangedEventHandler<T>(set_ItemsAdded);
     
    140130      set.CollectionReset += new CollectionItemsChangedEventHandler<T>(set_CollectionReset);
    141131      set.PropertyChanged += new PropertyChangedEventHandler(set_PropertyChanged);
    142     }
    143 
    144     event EventHandler IContent.ReadOnlyViewChanged {
    145       add { }
    146       remove { }
    147132    }
    148133
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ItemArray.cs

    r3381 r3390  
    3535  [StorableClass]
    3636  [Item("ItemArray<T>", "Represents an array of items.")]
    37   public class ItemArray<T> : ObservableArray<T>, IItem where T : class, IItem {
     37  public class ItemArray<T> : ObservableArray<T>, IItemArray<T> where T : class, IItem {
    3838    public virtual string ItemName {
    3939      get { return ItemAttribute.GetName(this.GetType()); }
     
    4646    }
    4747
    48     public ItemArray() : base() { }
    49     public ItemArray(int length) : base(length) { }
    50     public ItemArray(T[] array) : base(array) { }
    51     public ItemArray(IEnumerable<T> collection) : base(collection) { }
     48    [Storable]
     49    private T[] Items {
     50      get { return array; }
     51      set { array = value; }
     52    }
     53
     54    [Storable]
     55    private bool readOnlyView;
     56    public virtual bool ReadOnlyView {
     57      get { return readOnlyView; }
     58      set {
     59        if ((readOnlyView != value) && !(array.IsReadOnly)) {
     60          readOnlyView = value;
     61          OnReadOnlyViewChanged();
     62          OnPropertyChanged("ReadOnlyView");
     63        }
     64      }
     65    }
     66
     67    public ItemArray()
     68      : base() {
     69      readOnlyView = array.IsReadOnly;
     70    }
     71    public ItemArray(int length)
     72      : base(length) {
     73      readOnlyView = array.IsReadOnly;
     74    }
     75    public ItemArray(T[] array)
     76      : base(array) {
     77      readOnlyView = array.IsReadOnly;
     78    }
     79    public ItemArray(IEnumerable<T> collection)
     80      : base(collection) {
     81      readOnlyView = array.IsReadOnly;
     82    }
     83    [StorableConstructor]
     84    protected ItemArray(bool deserializing) { }
    5285
    5386    public object Clone() {
    5487      return Clone(new Cloner());
    5588    }
    56 
    5789    public virtual IDeepCloneable Clone(Cloner cloner) {
    5890      ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType());
    5991      cloner.RegisterClonedObject(this, clone);
    60       clone.ReadOnlyView = ReadOnlyView;
     92      clone.readOnlyView = readOnlyView;
    6193      clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray();
    6294      return clone;
     95    }
     96
     97    public new ReadOnlyItemArray<T> AsReadOnly() {
     98      return new ReadOnlyItemArray<T>(this);
    6399    }
    64100
     
    77113      if (handler != null) handler(this, EventArgs.Empty);
    78114    }
     115    public event EventHandler ReadOnlyViewChanged;
     116    protected virtual void OnReadOnlyViewChanged() {
     117      EventHandler handler = ReadOnlyViewChanged;
     118      if (handler != null) handler(this, EventArgs.Empty);
     119    }
    79120  }
    80121}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ItemCollection.cs

    r3381 r3390  
    3232  [StorableClass]
    3333  [Item("ItemCollection<T>", "Represents a collection of items.")]
    34   public class ItemCollection<T> : ObservableCollection<T>, IItem where T : class, IItem {
     34  public class ItemCollection<T> : ObservableCollection<T>, IItemCollection<T> where T : class, IItem {
    3535    public virtual string ItemName {
    3636      get { return ItemAttribute.GetName(this.GetType()); }
     
    4343    }
    4444
    45     public ItemCollection() : base() { }
    46     public ItemCollection(int capacity) : base(capacity) { }
    47     public ItemCollection(IEnumerable<T> collection) : base(collection) { }
     45    [Storable]
     46    private List<T> Items {
     47      get { return list; }
     48      set { list = value; }
     49    }
     50
     51    [Storable]
     52    private bool readOnlyView;
     53    public virtual bool ReadOnlyView {
     54      get { return readOnlyView; }
     55      set {
     56        if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) {
     57          readOnlyView = value;
     58          OnReadOnlyViewChanged();
     59          OnPropertyChanged("ReadOnlyView");
     60        }
     61      }
     62    }
     63
     64    public ItemCollection()
     65      : base() {
     66      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     67    }
     68    public ItemCollection(int capacity)
     69      : base(capacity) {
     70      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     71    }
     72    public ItemCollection(IEnumerable<T> collection)
     73      : base(collection) {
     74      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     75    }
     76    [StorableConstructor]
     77    protected ItemCollection(bool deserializing) { }
    4878
    4979    public object Clone() {
    5080      return Clone(new Cloner());
    5181    }
    52 
    5382    public virtual IDeepCloneable Clone(Cloner cloner) {
    5483      ItemCollection<T> clone = (ItemCollection<T>)Activator.CreateInstance(this.GetType());
    5584      cloner.RegisterClonedObject(this, clone);
    56       clone.ReadOnlyView = ReadOnlyView;
     85      clone.readOnlyView = readOnlyView;
    5786      clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    5887      return clone;
     88    }
     89
     90    public new ReadOnlyItemCollection<T> AsReadOnly() {
     91      return new ReadOnlyItemCollection<T>(this);
    5992    }
    6093
     
    73106      if (handler != null) handler(this, EventArgs.Empty);
    74107    }
     108    public event EventHandler ReadOnlyViewChanged;
     109    protected virtual void OnReadOnlyViewChanged() {
     110      EventHandler handler = ReadOnlyViewChanged;
     111      if (handler != null) handler(this, EventArgs.Empty);
     112    }
    75113  }
    76114}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs

    r3381 r3390  
    3535  [StorableClass]
    3636  [Item("ItemList<T>", "Represents a list of items.")]
    37   public class ItemList<T> : ObservableList<T>, IItem where T : class, IItem {
     37  public class ItemList<T> : ObservableList<T>, IItemList<T> where T : class, IItem {
    3838    public virtual string ItemName {
    3939      get { return ItemAttribute.GetName(this.GetType()); }
     
    4646    }
    4747
    48     public ItemList() : base() { }
    49     public ItemList(int capacity) : base(capacity) { }
    50     public ItemList(IEnumerable<T> collection) : base(collection) { }
     48    [Storable]
     49    private List<T> Items {
     50      get { return list; }
     51      set { list = value; }
     52    }
     53
     54    [Storable]
     55    private bool readOnlyView;
     56    public virtual bool ReadOnlyView {
     57      get { return readOnlyView; }
     58      set {
     59        if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) {
     60          readOnlyView = value;
     61          OnReadOnlyViewChanged();
     62          OnPropertyChanged("ReadOnlyView");
     63        }
     64      }
     65    }
     66
     67    public ItemList()
     68      : base() {
     69      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     70    }
     71    public ItemList(int capacity)
     72      : base(capacity) {
     73      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     74    }
     75    public ItemList(IEnumerable<T> collection)
     76      : base(collection) {
     77      readOnlyView = ((ICollection<T>)list).IsReadOnly;
     78    }
     79    [StorableConstructor]
     80    protected ItemList(bool deserializing) { }
    5181
    5282    public object Clone() {
    5383      return Clone(new Cloner());
    5484    }
    55 
    5685    public virtual IDeepCloneable Clone(Cloner cloner) {
    5786      ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType());
    5887      cloner.RegisterClonedObject(this, clone);
    59       clone.ReadOnlyView = ReadOnlyView;
     88      clone.readOnlyView = readOnlyView;
    6089      clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    6190      return clone;
     91    }
     92
     93    public new ReadOnlyItemList<T> AsReadOnly() {
     94      return new ReadOnlyItemList<T>(this);
    6295    }
    6396
     
    76109      if (handler != null) handler(this, EventArgs.Empty);
    77110    }
     111    public event EventHandler ReadOnlyViewChanged;
     112    protected virtual void OnReadOnlyViewChanged() {
     113      EventHandler handler = ReadOnlyViewChanged;
     114      if (handler != null) handler(this, EventArgs.Empty);
     115    }
    78116  }
    79117}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ItemSet.cs

    r3381 r3390  
    3535  [StorableClass]
    3636  [Item("ItemSet<T>", "Represents a set of items.")]
    37   public class ItemSet<T> : ObservableSet<T>, IItem where T : class, IItem {
     37  public class ItemSet<T> : ObservableSet<T>, IItemSet<T> where T : class, IItem {
    3838    public virtual string ItemName {
    3939      get { return ItemAttribute.GetName(this.GetType()); }
     
    4646    }
    4747
    48     public ItemSet() : base() { }
    49     public ItemSet(IEnumerable<T> collection) : base(collection) { }
     48    [Storable]
     49    private HashSet<T> Items {
     50      get { return set; }
     51      set { set = value; }
     52    }
     53
     54    [Storable]
     55    private bool readOnlyView;
     56    public virtual bool ReadOnlyView {
     57      get { return readOnlyView; }
     58      set {
     59        if ((readOnlyView != value) && !((ICollection<T>)set).IsReadOnly) {
     60          readOnlyView = value;
     61          OnReadOnlyViewChanged();
     62          OnPropertyChanged("ReadOnlyView");
     63        }
     64      }
     65    }
     66
     67    public ItemSet()
     68      : base() {
     69      readOnlyView = ((ICollection<T>)set).IsReadOnly;
     70    }
     71    public ItemSet(IEnumerable<T> collection)
     72      : base(collection) {
     73      readOnlyView = ((ICollection<T>)set).IsReadOnly;
     74    }
     75    [StorableConstructor]
     76    protected ItemSet(bool deserializing) { }
    5077
    5178    public object Clone() {
    5279      return Clone(new Cloner());
    5380    }
    54 
    5581    public virtual IDeepCloneable Clone(Cloner cloner) {
    5682      ItemSet<T> clone = (ItemSet<T>)Activator.CreateInstance(this.GetType());
    5783      cloner.RegisterClonedObject(this, clone);
    58       clone.ReadOnlyView = ReadOnlyView;
     84      clone.readOnlyView = readOnlyView;
    5985      clone.set = new HashSet<T>(this.Select(x => (T)cloner.Clone(x)));
    6086      return clone;
     87    }
     88
     89    public new ReadOnlyItemSet<T> AsReadOnly() {
     90      return new ReadOnlyItemSet<T>(this);
    6191    }
    6292
     
    75105      if (handler != null) handler(this, EventArgs.Empty);
    76106    }
     107    public event EventHandler ReadOnlyViewChanged;
     108    protected virtual void OnReadOnlyViewChanged() {
     109      EventHandler handler = ReadOnlyViewChanged;
     110      if (handler != null) handler(this, EventArgs.Empty);
     111    }
    77112  }
    78113}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/NamedItemCollection.cs

    r3381 r3390  
    3131  [Item("NamedItemCollection<T>", "Represents a collection of named items.")]
    3232  [StorableClass]
    33   public class NamedItemCollection<T> : ObservableKeyedCollection<string, T>, IItem where T : class, INamedItem {
    34     public virtual string ItemName {
    35       get { return ItemAttribute.GetName(this.GetType()); }
    36     }
    37     public virtual string ItemDescription {
    38       get { return ItemAttribute.GetDescription(this.GetType()); }
    39     }
    40     public virtual Image ItemImage {
    41       get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; }
    42     }
    43 
     33  public class NamedItemCollection<T> : KeyedItemCollection<string, T> where T : class, INamedItem {
    4434    public NamedItemCollection() : base() { }
    4535    public NamedItemCollection(int capacity) : base(capacity) { }
     
    4737      Initialize();
    4838    }
     39    [StorableConstructor]
     40    protected NamedItemCollection(bool deserializing) { }
    4941
    5042    [StorableHook(HookType.AfterDeserialization)]
     
    5345    }
    5446
    55     public object Clone() {
    56       return Clone(new Cloner());
    57     }
    58     public virtual IDeepCloneable Clone(Cloner cloner) {
    59       NamedItemCollection<T> clone = (NamedItemCollection<T>)Activator.CreateInstance(this.GetType());
    60       cloner.RegisterClonedObject(this, clone);
    61       clone.ReadOnlyView = ReadOnlyView;
    62       foreach (string key in dict.Keys)
    63         clone.dict.Add(key, (T)cloner.Clone(dict[key]));
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      NamedItemCollection<T> clone = (NamedItemCollection<T>)base.Clone(cloner);
    6449      clone.Initialize();
    6550      return clone;
    66     }
    67 
    68     public override string ToString() {
    69       return ItemName;
    70     }
    71 
    72     public event EventHandler ItemImageChanged;
    73     protected virtual void OnItemImageChanged() {
    74       EventHandler handler = ItemImageChanged;
    75       if (handler != null) handler(this, EventArgs.Empty);
    76     }
    77     public event EventHandler ToStringChanged;
    78     protected virtual void OnToStringChanged() {
    79       EventHandler handler = ToStringChanged;
    80       if (handler != null) handler(this, EventArgs.Empty);
    8151    }
    8252
  • trunk/sources/HeuristicLab.Core/3.3/Collections/OperationCollection.cs

    r3385 r3390  
    5151      parallel = false;
    5252    }
     53    [StorableConstructor]
     54    private OperationCollection(bool deserializing) { }
    5355
    5456    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorCollection.cs

    r3381 r3390  
    3535    public OperatorCollection() : base() { }
    3636    public OperatorCollection(IEnumerable<IOperator> collection) : base(collection) { }
     37    [StorableConstructor]
     38    protected OperatorCollection(bool deserializing) : base(deserializing) { }
    3739  }
    3840}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorList.cs

    r3381 r3390  
    3535    public OperatorList(int capacity) : base(capacity) { }
    3636    public OperatorList(IEnumerable<IOperator> collection) : base(collection) { }
     37    [StorableConstructor]
     38    protected OperatorList(bool deserializing) : base(deserializing) { }
    3739  }
    3840}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorSet.cs

    r3381 r3390  
    3434    public OperatorSet() : base() { }
    3535    public OperatorSet(IEnumerable<IOperator> collection) : base(collection) { }
     36    [StorableConstructor]
     37    protected OperatorSet(bool deserializing) : base(deserializing) { }
    3638  }
    3739}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ParameterCollection.cs

    r3381 r3390  
    3030    public ParameterCollection(int capacity) : base(capacity) { }
    3131    public ParameterCollection(IEnumerable<IParameter> collection) : base(collection) { }
     32    [StorableConstructor]
     33    protected ParameterCollection(bool deserializing) : base(deserializing) { }
    3234  }
    3335}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ScopeList.cs

    r3381 r3390  
    3232    public ScopeList(int capacity) : base(capacity) { }
    3333    public ScopeList(IEnumerable<IScope> collection) : base(collection) { }
     34    [StorableConstructor]
     35    private ScopeList(bool deserializing) : base(deserializing) { }
    3436
    3537    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Core/3.3/Collections/ValueParameterCollection.cs

    r3381 r3390  
    3030    public ValueParameterCollection(int capacity) : base(capacity) { }
    3131    public ValueParameterCollection(IEnumerable<IValueParameter> collection) : base(collection) { }
     32    [StorableConstructor]
     33    protected ValueParameterCollection(bool deserializing) : base(deserializing) { }
    3234  }
    3335}
  • trunk/sources/HeuristicLab.Core/3.3/Collections/VariableCollection.cs

    r3381 r3390  
    3232    public VariableCollection(int capacity) : base(capacity) { }
    3333    public VariableCollection(IEnumerable<IVariable> collection) : base(collection) { }
     34    [StorableConstructor]
     35    private VariableCollection(bool deserializing) : base(deserializing) { }
    3436
    3537    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r3384 r3390  
    102102    <Compile Include="Attributes\CreatableAttribute.cs" />
    103103    <None Include="HeuristicLabCorePlugin.cs.frame" />
     104    <Compile Include="Collections\ReadOnlyItemDictionary.cs" />
     105    <Compile Include="Collections\ItemDictionary.cs" />
     106    <Compile Include="Collections\ReadOnlyKeyedItemCollection.cs" />
     107    <Compile Include="Collections\KeyedItemCollection.cs" />
     108    <Compile Include="Collections\ReadOnlyItemSet.cs" />
     109    <Compile Include="Collections\ReadOnlyItemList.cs" />
     110    <Compile Include="Collections\ReadOnlyItemArray.cs" />
     111    <Compile Include="Collections\ReadOnlyItemCollection.cs" />
     112    <Compile Include="Collections\ItemArray.cs" />
     113    <Compile Include="Collections\ItemCollection.cs" />
     114    <Compile Include="Collections\ItemList.cs" />
     115    <Compile Include="Collections\ItemSet.cs" />
     116    <Compile Include="Collections\NamedItemCollection.cs" />
     117    <Compile Include="Collections\OperationCollection.cs" />
     118    <Compile Include="Collections\OperatorCollection.cs" />
     119    <Compile Include="Collections\OperatorList.cs" />
     120    <Compile Include="Collections\OperatorSet.cs" />
     121    <Compile Include="Collections\ParameterCollection.cs" />
     122    <Compile Include="Collections\ScopeList.cs" />
     123    <Compile Include="Collections\ValueParameterCollection.cs" />
     124    <Compile Include="Collections\VariableCollection.cs" />
     125    <Compile Include="Interfaces\IKeyedItemCollection.cs" />
     126    <Compile Include="Interfaces\IItemList.cs" />
     127    <Compile Include="Interfaces\IItemSet.cs" />
     128    <Compile Include="Interfaces\IItemDictionary.cs" />
     129    <Compile Include="Interfaces\IItemArray.cs" />
     130    <Compile Include="Interfaces\IItemCollection.cs" />
    104131    <Compile Include="Log.cs" />
    105132    <Compile Include="Executable.cs" />
     
    112139    <Compile Include="Interfaces\IExecutionContext.cs" />
    113140    <Compile Include="Interfaces\IOperation.cs" />
    114     <Compile Include="OperationCollection.cs" />
    115141    <Compile Include="ParameterizedNamedItem.cs" />
    116     <Compile Include="ValueParameterCollection.cs" />
    117142    <Compile Include="Interfaces\IValueLookupParameter.cs" />
    118143    <Compile Include="Interfaces\IValueParameter.cs" />
    119144    <Compile Include="Interfaces\ILookupParameter.cs" />
    120     <Compile Include="ItemArray.cs" />
    121145    <Compile Include="Engine.cs" />
    122146    <Compile Include="Interfaces\IScope.cs" />
     
    126150    <Compile Include="OperatorGraph.cs" />
    127151    <Compile Include="Interfaces\IParameter.cs" />
    128     <Compile Include="OperatorCollection.cs" />
    129     <Compile Include="ItemCollection.cs" />
    130     <Compile Include="OperatorSet.cs" />
    131     <Compile Include="ItemSet.cs" />
    132     <Compile Include="ItemList.cs" />
    133152    <Compile Include="Interfaces\IEngine.cs">
    134153      <SubType>Code</SubType>
    135154    </Compile>
    136155    <Compile Include="ExecutionContext.cs" />
    137     <Compile Include="OperatorList.cs" />
    138     <Compile Include="ParameterCollection.cs" />
    139     <Compile Include="VariableCollection.cs" />
    140     <Compile Include="ScopeList.cs" />
    141     <Compile Include="NamedItemCollection.cs" />
    142156    <Compile Include="Interfaces\INamedItem.cs" />
    143157    <Compile Include="Interfaces\IItem.cs" />
Note: See TracChangeset for help on using the changeset viewer.