// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; namespace ICSharpCode.SharpDevelop.Dom { /// /// Event handler for the event. /// /// /// We don't use the classic 'EventArgs' model for this event, because a EventArgs-class couldn't be covariant. /// public delegate void ModelCollectionChangedEventHandler(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems); /// /// A read-only collection that provides change notifications. /// /// /// We don't use INotifyCollectionChanged because that has the annoying 'Reset' update, /// where it's impossible for to detect what kind of changes happened unless the event consumer /// maintains a copy of the list. /// Also, INotifyCollectionChanged isn't type-safe. /// public interface IModelCollection : IReadOnlyCollection { event ModelCollectionChangedEventHandler CollectionChanged; /// /// Creates an immutable snapshot of the collection. /// IReadOnlyCollection CreateSnapshot(); } /// /// A collection that provides change notifications. /// public interface IMutableModelCollection : IModelCollection, ICollection { /// /// Gets the number of items in the collection. /// /// /// Disambiguates between IReadOnlyCollection.Count and ICollection.Count /// new int Count { get; } /// /// Adds the specified items to the collection. /// void AddRange(IEnumerable items); /// /// Removes all items matching the specified precidate. /// int RemoveAll(Predicate predicate); /// /// Can be used to group several operations into a batch update. /// The event will not fire during the batch update; /// instead the event will be raised a single time after the batch update finishes. /// IDisposable BatchUpdate(); } }