Esempio n. 1
0
        /// <summary>
        /// Sets the specified value and triggers all registered pre- or PostInterceptors
        /// </summary>
        /// <typeparam name="T">type of the value to be set</typeparam>
        /// <param name="target">A reference to the propertie´s backing-field</param>
        /// <param name="newValue">The value to be set</param>
        /// <param name="propertyName">Name of the property, for which the PropertyChanged-event should be raised/></param>
        /// <returns></returns>
        protected bool          Set <T>(ref T target, T newValue, string propertyName)
        {
            var settingEventArgs = new PropertySettingEventArgs <T>(target, newValue, propertyName);

            OnPreSet <T>(settingEventArgs);

            if (settingEventArgs.Cancel)
            {
                return(false);
            }

            target = newValue;

            OnPostSet(settingEventArgs.ToSetEventArgs());

            return(true);
        }
Esempio n. 2
0
        private void            OnPreSet <T>(PropertySettingEventArgs e)
        {
            var handler = _PreInterceptors + _PreSet;

            handler?.Invoke(_Sender, e);
        }