Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/28/09 21:38:15 (15 years ago)
Author:
swagner
Message:

Restructured interfaces and base classes (#819)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableDictionary.cs

    r2573 r2574  
    3030namespace HeuristicLab.Collections {
    3131  [Serializable]
    32   public class ObservableDictionary<TKey, TValue> : CollectionChangedEventsBase<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue> {
     32  public class ObservableDictionary<TKey, TValue> : IObservableDictionary<TKey, TValue> {
    3333    [Storable]
    3434    private Dictionary<TKey, TValue> dict;
     
    156156    }
    157157    #endregion
     158
     159    #region Events
     160    [field: NonSerialized]
     161    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsAdded;
     162    protected virtual void OnItemsAdded(IEnumerable<KeyValuePair<TKey, TValue>> items) {
     163      if (ItemsAdded != null)
     164        ItemsAdded(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     165    }
     166
     167    [field: NonSerialized]
     168    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsRemoved;
     169    protected virtual void OnItemsRemoved(IEnumerable<KeyValuePair<TKey, TValue>> items) {
     170      if (ItemsRemoved != null)
     171        ItemsRemoved(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items));
     172    }
     173
     174    [field: NonSerialized]
     175    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsReplaced;
     176    protected virtual void OnItemsReplaced(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
     177      if (ItemsReplaced != null)
     178        ItemsReplaced(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     179    }
     180
     181    [field: NonSerialized]
     182    public event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> CollectionReset;
     183    protected virtual void OnCollectionReset(IEnumerable<KeyValuePair<TKey, TValue>> items, IEnumerable<KeyValuePair<TKey, TValue>> oldItems) {
     184      if (CollectionReset != null)
     185        CollectionReset(this, new CollectionItemsChangedEventArgs<KeyValuePair<TKey, TValue>>(items, oldItems));
     186    }
     187    #endregion
    158188  }
    159189}
Note: See TracChangeset for help on using the changeset viewer.