Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Don't saves values in cases where value doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
netonjm authored and monojenkins committed Oct 31, 2019
1 parent 27bbb77 commit cf8910e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public Task SetValueAsync<T> (IPropertyInfo propertyInfo, ValueInfo<T> value, Pr
return Task.FromException (new ArgumentNullException (nameof (propertyInfo)));

if (propertyInfo is DescriptorPropertyInfo info && info.CanWrite) {

var actualValue = info.GetValue<T> (this.Target);
if (info.GetValue<T> (this.Target).Equals (value.Value)) {
return Task.CompletedTask;
}

//this is an exception for null/empty cases of string
if (typeof (T) == typeof(string) && string.IsNullOrEmpty (actualValue as string) && string.IsNullOrEmpty (value.Value as string)) {
return Task.CompletedTask;
}
info.SetValue (this.Target, value.Value);
RaisePropertyChanged (info);
} else {
Expand Down

0 comments on commit cf8910e

Please sign in to comment.