Click here to Skip to main content
15,886,639 members
Articles / Programming Languages / C#

INotifyPropertyChanged and beyond - Part II

Rate me:
Please Sign up or sign in to vote.
4.97/5 (16 votes)
30 May 2007CPOL11 min read 69.8K   707   71  
Add support for event suppression and event propagation
using System;
using System.ComponentModel;

namespace NotifyTest {
	/// <summary>
	/// This class extends <see cref="T:PropertyNotificationEventArgs"/> to
	/// support objects that implement the <see cref="T:IList{T}"/> interface.
	/// </summary>
	public class ListPropertyNotificationEventArgs : PropertyNotificationEventArgs {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="ListPropertyNotificationEventArgs"/> class.
		/// </summary>
		/// <param name="propertyName">
		/// The name of the property that is associated with this
		/// notification.
		/// </param>
		public ListPropertyNotificationEventArgs(String propertyName)
			: base(propertyName) {
			this.index = -1;
			this.operation = ListOperation.Unknown;
		}

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="ListPropertyNotificationEventArgs"/> class.
		/// </summary>
		/// <param name="propertyName">
		/// The name of the property that is associated with this
		/// notification.
		/// </param>
		/// <param name="oldValue">The old value.</param>
		/// <param name="newValue">The new value.</param>
		public ListPropertyNotificationEventArgs(String propertyName,
			Object oldValue, Object newValue)
			: base(propertyName, oldValue, newValue) {
			this.index = -1;
			this.operation = ListOperation.Unknown;
		}

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="ListPropertyNotificationEventArgs"/> class.
		/// </summary>
		/// <param name="propertyName">The name of the property that is associated with this
		/// notification.</param>
		/// <param name="operation">The operation.</param>
		/// <param name="index">The index.</param>
		/// <param name="oldValue">The old value.</param>
		/// <param name="newValue">The new value.</param>
		public ListPropertyNotificationEventArgs(String propertyName,
			ListOperation operation, Int32 index,
			Object oldValue, Object newValue)
			: base(propertyName, oldValue, newValue) {
			this.index = index;
			this.operation = operation;
		}

		#endregion // Constructors

		#region Properties/Fields

		/// <summary>
		/// Holds the index into the list that was affected by the
		/// operation.
		/// </summary>
		private Int32 index;

		/// <summary>
		/// Gets the index into the list that was affected by the
		/// operation.
		/// </summary>
		/// <value>The index.</value>
		public Int32 Index {
			get {
				return this.index;
			}
		}

		/// <summary>
		/// Holds the operation that was performed on the list.
		/// </summary>
		private ListOperation operation;

		/// <summary>
		/// Gets the operation that was performed on the list.
		/// </summary>
		/// <value>The operation.</value>
		public ListOperation Operation {
			get {
				return this.operation;
			}
		}

		#endregion // Properties/Fields
	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer SQL Farms, Inc.
United States United States
My name is Tom Goff and I have been working as a Software Engineer for over 15 years. Over my career, I have primarily focused on Windows programming with C++ and C#. I have also worked extensively with Microsoft SQL Server over the past 6 years.

Comments and Discussions