Click here to Skip to main content
15,892,298 members
Articles / Programming Languages / C# 4.0

Enterprise Variables for WF4

Rate me:
Please Sign up or sign in to vote.
4.95/5 (21 votes)
23 Sep 2010CPOL23 min read 59.2K   810   39  
This article describes the design, implementation and usage of the Enterprise Variables stored in the Repository.
//*****************************************************************************
//    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.

License

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


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions