|
using System.Collections.Generic;
using System.ComponentModel;
namespace CodeProject.VisualStudio.QualityTools.UnitTestFramework
{
public sealed class PropertyChangedWatcher
{
private INotifyPropertyChanged watchedObject;
private List<PropertyChangedEventArgs> events = new List<PropertyChangedEventArgs>();
public PropertyChangedWatcher(INotifyPropertyChanged watchedObject)
{
this.watchedObject = watchedObject;
this.watchedObject.PropertyChanged += watchedObject_PropertyChanged;
}
public void Reset()
{
events.Clear();
}
public IEnumerator<PropertyChangedEventArgs> Find(string propertyName)
{
foreach (PropertyChangedEventArgs e in events)
{
if (e.PropertyName.Equals(propertyName))
{
yield return e;
}
}
}
void watchedObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
events.Add(e);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Windows developer with 10+ years experience working in the banking industry.