Free cookie consent management tool by TermsFeed Policy Generator

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

Refactored HeuristicLab.Collections (#977)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) {
Note: See TracChangeset for help on using the changeset viewer.