protected override bool ShouldHandlerSerialize(PropertyChangingEventHandler value)
 {
     if (value.Method.DeclaringType != null && value.Method.DeclaringType.Name == @"Action`2")
       {
       return false;
       }
       return base.ShouldHandlerSerialize(value);
 }
        protected void OnPropertyChanging([CallerMemberName] string propertyName = null)
        {
            PropertyChangingEventHandler eventHandler = this.PropertyChanging;

            if (eventHandler != null)
            {
                eventHandler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
    protected void OnPropertyChanging(string name)
    {
        PropertyChangingEventHandler handler = PropertyChanging;

        if (handler != null)
        {
            handler(this, new PropertyChangingEventArgs(name));
        }
    }
Exemple #4
0
        protected virtual void NotifyPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler handler = PropertyChanging;

            if (handler != null)
            {
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #5
0
        /// <summary>
        /// 调度属性值将要更改的事件。
        /// </summary>
        /// <param name="propertyName">将要更改的属性名。</param>
        private void OnPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler changing = PropertyChanging;

            if (!isInEdit && changing != null)
            {
                changing(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #6
0
        protected void OnValueChanged(string i)
        {
            PropertyChangingEventHandler c = this.ValueChanged;

            if (c != null)
            {
                c(this, new PropertyChangingEventArgs(i));
            }
        }
        protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
        {
            PropertyChangingEventHandler changing = PropertyChanging;

            if (changing != null)
            {
                changing(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #8
0
        protected void SendPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler handler = this.PropertyChanging;

            if (handler != null)
            {
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
        public void UnregisterNotificationHandler(string propertyName, PropertyChangingEventHandler handler)
        {
            Contract.Requires <ArgumentNullException>(handler != null);

            if (_changingHandlers.ContainsKey(propertyName))
            {
                _changingHandlers[propertyName] = _changingHandlers[propertyName] -= handler;
            }
        }
Exemple #10
0
        protected void OnPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler propertyChanging = PropertyChanging;

            if (propertyChanging != null)
            {
                propertyChanging.Invoke(this, new PropertyChangingEventArgs(propertyName));
            }
        }
        void ISupportChangeNotification.NotifyPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler handler = PropertyChanging;

            if (handler != null)
            {
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #12
0
        public static IDisposable ListenPropertyChanging(
            this INotifyPropertyChanging source,
            Action <PropertyChangingEventArgs> handler)
        {
            var h = new PropertyChangingEventHandler((_, e) => handler(e));

            source.PropertyChanging += h;
            return(Disposable.Create(() => source.PropertyChanging -= h));
        }
        public virtual void RaisePropertyChanging <T>(Expression <Func <T> > propertyExpression)
        {
            PropertyChangingEventHandler handler = PropertyChanging;

            if (handler != null)
            {
                string propertyName = GetPropertyName(propertyExpression);
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #14
0
        // Token: 0x060012D5 RID: 4821 RVA: 0x00065B38 File Offset: 0x00063D38
        protected virtual void OnPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler propertyChanging = this.PropertyChanging;

            if (propertyChanging == null)
            {
                return;
            }
            propertyChanging(this, new PropertyChangingEventArgs(propertyName));
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Raises the PropertyChanging event if needed.
        /// </summary>
        ///
        /// <remarks>
        ///     Anwar Javed, 03/30/2014 10:01 PM.
        /// </remarks>
        ///
        /// <typeparam name="T">
        ///     The type of the property that changes.
        /// </typeparam>
        /// <param name="propertyExpression">
        ///     An expression identifying the property that changes.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        protected virtual void RaisePropertyChanging <T>(Expression <Func <T> > propertyExpression)
        {
            PropertyChangingEventHandler propertyChanging = this.PropertyChanging;

            if (propertyChanging != null)
            {
                string propertyName = GetPropertyName <T>(propertyExpression);
                propertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #16
0
        /// <summary>
        /// Raises the PropertyChanging event if needed.
        /// </summary>
        /// <typeparam name="T">The type of the property that
        /// changes.</typeparam>
        /// <param name="propertyExpression">An expression identifying the property
        /// that changes.</param>
        protected virtual void RaisePropertyChanging <T>(Expression <Func <T> > propertyExpression)
        {
            PropertyChangingEventHandler handler = this.PropertyChanging;

            if (handler != null)
            {
                string propertyName = ObservableObject.GetPropertyName <T>(propertyExpression);
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
Exemple #17
0
        private void OnPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler changingEventHandler = this.PropertyChanging;

            if (changingEventHandler == null)
            {
                return;
            }
            changingEventHandler((object)this, new PropertyChangingEventArgs(propertyName));
        }
        private void NotifyPropertyChanging(String propertyName)
        {
            PropertyChangingEventHandler handler = PropertyChanging;

            if (null != handler)
            {
                PropertyChangingEventArgs args = new PropertyChangingEventArgs(propertyName);
                handler(this, args);
            }
        }
Exemple #19
0
 protected internal virtual void OnPropertyChanging(PropertyChangingEventArgs e)
 {
     if (!this._initializing && (this._events != null))
     {
         PropertyChangingEventHandler handler = (PropertyChangingEventHandler)this._events[PropertyChangingEventKey];
         if (handler != null)
         {
             handler(this, e);
         }
     }
 }
Exemple #20
0
 protected virtual void SendPropertyChanging()
 {
     if (this.PropertyChanging != null)
     {
         PropertyChangingEventHandler propertyChangingEvent = this.PropertyChanging;
         if (propertyChangingEvent != null)
         {
             propertyChangingEvent(this, emptyChangingEventArgs);
         }
     }
 }
Exemple #21
0
        /// <summary>
        ///     Raises the <see cref="PropertyChanging" /> event.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        protected virtual void OnPropertyChanging(string propertyName)
        {
            VerifyPropertyName(propertyName);

            PropertyChangingEventHandler eventHandler = this.PropertyChanging;

            if (eventHandler != null)
            {
                eventHandler(this, new PropertyChangingEventArgs(propertyName));
            }
        }
 public static void NotifyProperty <T>(object sender, PropertyChangingEventHandler changing, PropertyChangedEventHandler changed, ref T location, T value, string property)
 {
     Debug.Assert(sender.GetType().GetProperty(property) != null);
     changing?.Invoke(sender, new PropertyChangingEventArgs(property));
     if (EqualityComparer <T> .Default.Equals(location, value))
     {
         return;
     }
     location = value;
     changed?.Invoke(sender, new PropertyChangedEventArgs(property));
 }
Exemple #23
0
    protected virtual void OnPropertyChanging(string propertyName)
    {
        this.ValidateProperty(propertyName);

        PropertyChangingEventHandler handler = this.PropertyChanging;

        if (null != handler)
        {
            handler(this, new PropertyChangingEventArgs(propertyName));
        }
    }
        public void UnregisterNotificationHandler(string propertyName, PropertyChangingEventHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler), "Contract assertion not met: handler != null");
            }

            if (_changingHandlers.ContainsKey(propertyName))
            {
                _changingHandlers[propertyName] = _changingHandlers[propertyName] -= handler;
            }
        }
Exemple #25
0
        public static bool Notify <T, TValue>(this T instance, PropertyChangingEventHandler handler, Expression <Func <T, TValue> > selector, TValue oldValue, TValue newValue)
            where T : INotifyPropertyChanging
        {
            if (handler == null)
            {
                return(false);
            }
            PropertyValueChangingEventArgs <TValue> propertyValueChangingEventArg = new PropertyValueChangingEventArgs <TValue>(Name.Of <T, TValue>(selector), oldValue, newValue);

            handler(instance, propertyValueChangingEventArg);
            return(propertyValueChangingEventArg.IsCancelled);
        }
Exemple #26
0
        /// <summary>
        ///     Create an observable for the INotifyPropertyChanging
        /// </summary>
        /// <param name="source">INotifyPropertyChanging</param>
        /// <param name="propertyNamePattern">Optional property name / pattern</param>
        /// <typeparam name="T">INotifyPropertyChanging</typeparam>
        /// <returns>IObservable with PropertyChangingEventArgs</returns>
        public static IObservable <PropertyChangingEventArgs> OnPropertyChanging <T>(this T source, string propertyNamePattern = null)
            where T : INotifyPropertyChanging
        {
            var observable = Observable.Create <PropertyChangingEventArgs>(observer =>
            {
                PropertyChangingEventHandler handler = (s, e) => observer.OnNext(e);
                source.PropertyChanging += handler;
                return(Disposable.Create(() => source.PropertyChanging -= handler));
            });

            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            // Create predicate
            Func <PropertyChangingEventArgs, bool> predicate;

            if (!string.IsNullOrEmpty(propertyNamePattern) && propertyNamePattern != "*")
            {
                predicate = propertyChangedEventArgs =>
                {
                    try
                    {
                        var propertyName = propertyChangedEventArgs.PropertyName;
                        if (string.IsNullOrEmpty(propertyName))
                        {
                            return(true);
                        }
                        if (propertyNamePattern.Contains("*") || propertyNamePattern.Contains("."))
                        {
                            if (Regex.IsMatch(propertyName, propertyNamePattern))
                            {
                                return(true);
                            }
                        }

                        return(propertyName == "*" || propertyNamePattern == propertyName);
                    }
                    catch (Exception ex)
                    {
                        Log.Error().WriteLine(ex, "Error in predicate for OnPropertyChanging");
                    }
                    return(false);
                };
            }
            else
            {
                predicate = args => true;
            }

            return(observable.Where(predicate));
        }
Exemple #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Reactor"/> class.
        /// </summary>
        public Reactor(object target, PropertyChangedEventHandler propertyChangedHandler,
                       PropertyChangingEventHandler propertyChangingHandler)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            this.Target = target;
            this.PropertyChangedHandler  = propertyChangedHandler;
            this.PropertyChangingHandler = propertyChangingHandler;
        }
Exemple #28
0
        /// <summary>
        /// Unsubscribes the specified event handler.
        /// </summary>
        /// <param name="handler">The event handler to unsubscribe from.</param>
        /// <param name="value">The event handler to unsubscribe.</param>
        public static void Unsubscribe(ref PropertyChangingEventHandler handler, PropertyChangingEventHandler value)
        {
            PropertyChangingEventHandler comparand;
            PropertyChangingEventHandler location = handler;

            do
            {
                comparand = location;

                location = Interlocked.CompareExchange(ref handler, (PropertyChangingEventHandler)Delegate.Remove(comparand, value), comparand);
            }while (location != comparand);
        }
Exemple #29
0
        /// <summary>
        /// Check existence of property and fire <see cref="PropertyChanging"/> event.
        /// </summary>
        /// <param name="propertyName">Changed property name.</param>
        protected virtual void OnPropertyChanging(string propertyName)
        {
            VerifyPropertyName(propertyName);

            PropertyChangingEventHandler handler = PropertyChanging;

            if (handler != null)
            {
                var e = new PropertyChangingEventArgs(propertyName);
                handler(this, e);
            }
        }
Exemple #30
0
        // Protected Methods (1) 

        /// <summary>
        /// Raises the <see cref="EntityBase.PropertyChanging" /> event.
        /// </summary>
        /// <param name="propertyName">The name of the property to raise the event for.</param>
        /// <returns>Event was raised or not because no delegate is linked with it.</returns>
        /// <exception cref="ArgumentException"><paramref name="propertyName" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="propertyName" /> has an invalid format.
        /// </exception>
        protected bool OnPropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler handler = this.PropertyChanging;

            if (handler != null)
            {
                handler(this, new PropertyChangingEventArgs(propertyName));
                return(true);
            }

            // no delegate linked
            return(false);
        }
Exemple #31
0
        public static void UnsubscribeFromPropertyChangingEvent(this IList items,
                                                                PropertyChangingEventHandler eventHandler)
        {
            if (items == null)
            {
                return;
            }

            foreach (var item in items.OfType <INotifyPropertyChanging>())
            {
                item.PropertyChanging -= eventHandler;
            }
        }
        public void NotifyPropertyChanged_ing()
        {
            bool hasChanged = false;
            bool hasChanging = false;

            PropertyChangedEventHandler changedHandler = new PropertyChangedEventHandler(delegate(object sender, PropertyChangedEventArgs e) { hasChanged = true; });
            PropertyChangingEventHandler changingHanlder = new PropertyChangingEventHandler(delegate(object sender, PropertyChangingEventArgs e) { hasChanging = true; });

            obj.PropertyChanged += changedHandler;
            obj.PropertyChanging += changingHanlder;

            obj.NotifyPropertyChanging("TestString", null, null);
            obj.TestString = "test";
            obj.NotifyPropertyChanged("TestString", null, null);

            Assert.That(hasChanged, Is.True);
            Assert.That(hasChanging, Is.True);

            obj.PropertyChanged -= changedHandler;
            obj.PropertyChanging -= changingHanlder;
        }
        public void UnregisterNotificationHandler(string propertyName, PropertyChangingEventHandler handler)
        {
            Contract.Requires<ArgumentNullException>(handler != null);

            if (_changingHandlers.ContainsKey(propertyName))
            {
                _changingHandlers[propertyName] = _changingHandlers[propertyName] -= handler;
            }
        }
Exemple #34
0
 /// <summary>
 /// Override this method to change the default logic for determining 
 /// if the event handler should be serialized
 /// </summary>
 /// <param name="value">the event handler to review</param>
 /// <returns></returns>
 protected virtual bool ShouldHandlerSerialize(PropertyChangingEventHandler value)
 {
   return value.Method.IsPublic &&
          value.Method.DeclaringType != null &&
          (value.Method.DeclaringType.IsSerializable || value.Method.IsStatic);
 }
 internal StandardChangeTracker(CommonDataServices services) {
     this.services = services;
     this.items = new Dictionary<object, StandardTrackedObject>();
     this.onPropertyChanging = new PropertyChangingEventHandler(this.OnPropertyChanging);
 }