//***************************************************************************** // Description.....WF4 Message Mediation Library // // Author..........Roman Kiss, rkiss@pathcom.com // Copyright © 2010 ATZ Consulting Inc. (see included license.rtf file) // // Date Created: 09/09/10 // // Date Modified By Description //----------------------------------------------------------------------------- // 09/09/10 Roman Kiss Initial Revision, based on MS Sequence activity // //***************************************************************************** // #region Namespaces using System; using System.Collections.ObjectModel; #endregion namespace RKiss.ActivityLib { public class ValidatingCollection<T> : Collection<T> { // Methods protected override void ClearItems() { this.OnMutate(); base.ClearItems(); } protected override void InsertItem(int index, T item) { this.OnAdd(item); base.InsertItem(index, item); } private void OnAdd(T item) { if (this.OnAddValidationCallback != null) { this.OnAddValidationCallback(item); } } private void OnMutate() { if (this.OnMutateValidationCallback != null) { this.OnMutateValidationCallback(); } } protected override void RemoveItem(int index) { this.OnMutate(); base.RemoveItem(index); } protected override void SetItem(int index, T item) { this.OnAdd(item); this.OnMutate(); base.SetItem(index, item); } // Properties public Action<T> OnAddValidationCallback { get; set; } public Action OnMutateValidationCallback { get; set; } } }
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.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)