// ----------------------------------------------------------------------- // // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Reactive.Linq; public class PerspexList : ObservableCollection { public PerspexList() { this.Initialize(); } public PerspexList(IEnumerable items) : base(items) { this.Initialize(); } public IObservable Changed { get; private set; } public void AddRange(IEnumerable items) { foreach (T item in items) { this.Add(item); } } private void Initialize() { this.Changed = Observable.FromEvent( handler => (sender, e) => handler(e), handler => this.CollectionChanged += handler, handler => this.CollectionChanged -= handler); } } }