Invert WatchProperty(...) methods' watchInitialValue

This commit is contained in:
Tyrrrz 2024-07-19 02:00:47 +03:00
parent 281e0f608a
commit 42e6de359e
2 changed files with 4 additions and 9 deletions

View File

@ -65,8 +65,7 @@ public class App : Application, IDisposable
}; };
InitializeTheme(); InitializeTheme();
}, }
false
) )
); );
} }

View File

@ -11,15 +11,11 @@ internal static class NotifyPropertyChangedExtensions
this TOwner owner, this TOwner owner,
Expression<Func<TOwner, TProperty>> propertyExpression, Expression<Func<TOwner, TProperty>> propertyExpression,
Action callback, Action callback,
bool watchInitialValue = true bool watchInitialValue = false
) )
where TOwner : INotifyPropertyChanged where TOwner : INotifyPropertyChanged
{ {
var memberExpression = var memberExpression = propertyExpression.Body as MemberExpression;
propertyExpression.Body as MemberExpression
// Property value might be boxed inside a conversion expression, if the types don't match
?? (propertyExpression.Body as UnaryExpression)?.Operand as MemberExpression;
if (memberExpression?.Member is not PropertyInfo property) if (memberExpression?.Member is not PropertyInfo property)
throw new ArgumentException("Provided expression must reference a property."); throw new ArgumentException("Provided expression must reference a property.");
@ -45,7 +41,7 @@ internal static class NotifyPropertyChangedExtensions
public static IDisposable WatchAllProperties<TOwner>( public static IDisposable WatchAllProperties<TOwner>(
this TOwner owner, this TOwner owner,
Action callback, Action callback,
bool watchInitialValues = true bool watchInitialValues = false
) )
where TOwner : INotifyPropertyChanged where TOwner : INotifyPropertyChanged
{ {