diff --git a/Nuclex.Support (Xbox 360).csproj b/Nuclex.Support (Xbox 360).csproj index ca11d6d..39811ff 100644 --- a/Nuclex.Support (Xbox 360).csproj +++ b/Nuclex.Support (Xbox 360).csproj @@ -69,6 +69,7 @@ AssertHelper.cs + ItemEventArgs.cs diff --git a/Nuclex.Support.csproj b/Nuclex.Support.csproj index 044e686..386c2d7 100644 --- a/Nuclex.Support.csproj +++ b/Nuclex.Support.csproj @@ -51,6 +51,7 @@ AssertHelper.cs + ItemEventArgs.cs diff --git a/Source/Collections/IObservableCollection.cs b/Source/Collections/IObservableCollection.cs new file mode 100644 index 0000000..51cc620 --- /dev/null +++ b/Source/Collections/IObservableCollection.cs @@ -0,0 +1,47 @@ +#region CPL License +/* +Nuclex Framework +Copyright (C) 2002-2009 Nuclex Development Labs + +This library is free software; you can redistribute it and/or +modify it under the terms of the IBM Common Public License as +published by the IBM Corporation; either version 1.0 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +IBM Common Public License for more details. + +You should have received a copy of the IBM Common Public +License along with this library +*/ +#endregion + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Nuclex.Support.Collections { + + /// Interface for collections that can be observed + /// Type of items managed in the collection + interface IObservableCollection { + + /// Raised when an item has been added to the collection + event EventHandler> ItemAdded; + + /// Raised when an item is removed from the collection + event EventHandler> ItemRemoved; + + /// Raised when the collection is about to be cleared + /// + /// This could be covered by calling ItemRemoved for each item currently + /// contained in the collection, but it is often simpler and more efficient + /// to process the clearing of the entire collection as a special operation. + /// + event EventHandler Clearing; + + } + +} // namespace Nuclex.Support.Collections diff --git a/Source/Collections/ObservableCollection.cs b/Source/Collections/ObservableCollection.cs index e8e6612..73f629e 100644 --- a/Source/Collections/ObservableCollection.cs +++ b/Source/Collections/ObservableCollection.cs @@ -25,7 +25,8 @@ using System.Collections.ObjectModel; namespace Nuclex.Support.Collections { /// Collection which fires events when items are added or removed - public class ObservableCollection : Collection { + public class ObservableCollection : + Collection, IObservableCollection { /// Raised when an item has been added to the collection public event EventHandler> ItemAdded; diff --git a/Source/Collections/ObservableDictionary.cs b/Source/Collections/ObservableDictionary.cs index efa8c68..402bd76 100644 --- a/Source/Collections/ObservableDictionary.cs +++ b/Source/Collections/ObservableDictionary.cs @@ -36,7 +36,8 @@ namespace Nuclex.Support.Collections { IDeserializationCallback, #endif IDictionary, - IDictionary { + IDictionary, + IObservableCollection> { #if !COMPACTFRAMEWORK #region class SerializedDictionary