protected override bool ShouldHandlerSerialize(PropertyChangingEventHandler value)
 {
     if (value.Method.DeclaringType != null && value.Method.DeclaringType.Name == @"Action`2")
       {
       return false;
       }
       return base.ShouldHandlerSerialize(value);
 }
        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;
        }
Example #3
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);
 }
        public void UnregisterNotificationHandler(string propertyName, PropertyChangingEventHandler handler)
        {
            Contract.Requires<ArgumentNullException>(handler != null);

            if (_changingHandlers.ContainsKey(propertyName))
            {
                _changingHandlers[propertyName] = _changingHandlers[propertyName] -= handler;
            }
        }