wasSharp – Blame information for rev 27

Subversion Repositories:
Rev:
Rev Author Line No. Line
10 office 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. //
5 ///////////////////////////////////////////////////////////////////////////
6  
7 using System;
8 using System.Collections.Generic;
9 using System.Collections.ObjectModel;
10 using System.Collections.Specialized;
11  
12 namespace wasSharp.Collections.Specialized
13 {
14 /// <summary>
15 /// An observable collection allowing the add of a range of items.
16 /// </summary>
17 /// <typeparam name="T">the collection type</typeparam>
18 public class ExtendedObservableCollection<T> : ObservableCollection<T>
19 {
20 private bool _suppressNotification;
21  
22 protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
23 {
24 if (!_suppressNotification)
25 base.OnCollectionChanged(e);
26 }
27  
28 public void AddRange(IEnumerable<T> list)
29 {
30 if (list == null)
31 throw new ArgumentNullException(nameof(list));
32  
33 _suppressNotification = true;
34  
35 foreach (var item in list)
36 {
37 Add(item);
38 }
39 _suppressNotification = false;
40 OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
41 }
42 }
27 office 43 }