|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace SongBird.Infrastructure
{
/// <summary>
/// Base class which implements change notification.
/// </summary>
public abstract class NotificationBase : INotifyPropertyChanged
{
/// <summary>
/// Instantiate a new instance of <see cref="NotificationBase"/>.
/// </summary>
public NotificationBase()
{
Initialize();
}
/// <summary>
/// Override this method to perform any initialization.
/// </summary>
protected virtual void Initialize() { }
/// <summary>
/// Raise the change notifications.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
protected virtual void Changed(string propertyName)
{
PropertyChangedEventHandler handler = _propertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
#region INotifyPropertyChanged Members
private PropertyChangedEventHandler _propertyChanged;
/// <summary>
/// Property changed event handler.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; }
remove { _propertyChanged -= value; }
}
#endregion
}
}
|
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.
A developer for over 30 years, I've been lucky enough to write articles and applications for Code Project as well as the Intel Ultimate Coder - Going Perceptual challenge. I live in the North East of England with 2 wonderful daughters and a wonderful wife.
I am not the Stig, but I do wish I had Lotus Tuned Suspension.