Example #1
0
        protected void SetFieldValue(string propertyName, string filedName, object value)
        {
            PropertyInfo pi = this.GetType().GetProperty(propertyName);
            FieldInfo fi = this.GetType().GetField(filedName, BindingFlags.NonPublic
                | BindingFlags.Public | BindingFlags.Instance);
            if (fi.GetValue(this) == value) return;

            PropertyChangingEventArgs e = new PropertyChangingEventArgs() { PropertyName = pi.Name, PropertyValue = pi.GetValue(this, null) };
            OnPropertyChanging(e);
            if (!e.Cancel)
            {
                fi.SetValue(this, value);
                OnPropertyChanged(new PropertyChangedEventArgs() { PropertyName = pi.Name, PropertyValue = pi.GetValue(this, null) });
            }
        }
Example #2
0
 protected virtual void OnPropertyChanging(PropertyChangingEventArgs e)
 {
     if (PropertyChanging != null)
         PropertyChanging(this, e);
 }
Example #3
0
 protected virtual void OnPropertyChanging(PropertyChangingEventArgs e)
 {
     if (PropertyChanging != null)
         PropertyChanging(this, e);
 }