PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.TestSupport/CollectionChangedTracker.cs

#
C# | 42 lines | 22 code | 4 blank | 16 comment | 0 complexity | 7f30b71446af3b0a45eef8830d0d61a1 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Collections.Specialized;
  20. using System.Linq;
  21. using System.Text;
  22. namespace Microsoft.Practices.Prism.TestSupport
  23. {
  24. public class CollectionChangedTracker
  25. {
  26. private readonly List<NotifyCollectionChangedEventArgs> eventList = new List<NotifyCollectionChangedEventArgs>();
  27. public CollectionChangedTracker(INotifyCollectionChanged collection)
  28. {
  29. collection.CollectionChanged += OnCollectionChanged;
  30. }
  31. public IEnumerable<NotifyCollectionChangedAction> ActionsFired { get { return this.eventList.Select(e => e.Action); } }
  32. public IEnumerable<NotifyCollectionChangedEventArgs> NotifyEvents { get { return this.eventList; } }
  33. private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  34. {
  35. this.eventList.Add(e);
  36. }
  37. }
  38. }