Exemple #1
0
        /// <summary>
        /// This is called to check whether the user has assigned an event handler to
        /// catch data modification.
        /// </summary>
        /// <returns></returns>
        private bool target_CanModifyData(Control aSubject)
        {
            bool result = true;
            //I love how you can get round most C# limitations with a second variable of the same
            //type pointing to the same reference.
            BeforeDataModificationDelegate BeforeValueModified = target.GetBeforeValueModified();

            if (BeforeValueModified != null)
            {
                BeforeDataModification e = new BeforeDataModification(aSubject);
                BeforeValueModified(this, e);
                result = e.AllowChange;
            }

            if (!result)
            {
                Revert();       //go back to what we had before (this will probably screw up the modified state..)
            }
            return(result);
        }
 protected virtual void BeforeValueModified(object sender, BeforeDataModification e)
 {
 }
 private void mo_BeforeValueModified(object sender, BeforeDataModification e)
 {
     BeforeValueModified(sender, e);
 }