From 1b5c674fd38499f82f2a47d9cfda4d1f54b39daa Mon Sep 17 00:00:00 2001 From: BoBoBaSs84 <73112377+BoBoBaSs84@users.noreply.github.com> Date: Mon, 20 May 2024 16:32:09 +0200 Subject: [PATCH] feat: make methods protected closes #96 --- src/BB84.Notifications/Commands/AsyncActionCommand.cs | 4 ++-- src/BB84.Notifications/NotifiableObject.cs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/BB84.Notifications/Commands/AsyncActionCommand.cs b/src/BB84.Notifications/Commands/AsyncActionCommand.cs index a84e2c7..90de16b 100644 --- a/src/BB84.Notifications/Commands/AsyncActionCommand.cs +++ b/src/BB84.Notifications/Commands/AsyncActionCommand.cs @@ -19,7 +19,7 @@ public sealed class AsyncActionCommand(Func<Task> execute, Func<bool>? canExecut /// <inheritdoc/> public bool CanExecute() - => !_isExecuting && (canExecute?.Invoke() ?? true); + => CanExecute(null); /// <inheritdoc/> public async Task ExecuteAsync() @@ -42,7 +42,7 @@ public async Task ExecuteAsync() /// <inheritdoc/> public bool CanExecute(object? parameter) - => CanExecute(); + => !_isExecuting && (canExecute?.Invoke() ?? true); /// <inheritdoc/> public void Execute(object? parameter) diff --git a/src/BB84.Notifications/NotifiableObject.cs b/src/BB84.Notifications/NotifiableObject.cs index 8939d56..cd994ee 100644 --- a/src/BB84.Notifications/NotifiableObject.cs +++ b/src/BB84.Notifications/NotifiableObject.cs @@ -44,7 +44,7 @@ protected void SetProperty<T>(ref T fieldValue, T newValue, [CallerMemberName] s /// Raises the <see cref="PropertyChanged"/> event. /// </summary> /// <param name="propertyName">The name of the calling property.</param> - private void RaisePropertyChanged(string propertyName) + protected void RaisePropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new(propertyName)); /// <summary> @@ -53,22 +53,23 @@ private void RaisePropertyChanged(string propertyName) /// <typeparam name="T">The type to work with.</typeparam> /// <param name="propertyName">The name of the calling property.</param> /// <param name="value">The value of the calling property.</param> - private void RaisePropertyChanged<T>(string propertyName, T value) + protected void RaisePropertyChanged<T>(string propertyName, T value) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs<T>(propertyName, value)); /// <summary> /// Raises the <see cref="PropertyChanging"/> event. /// </summary> /// <param name="propertyName">The name of the calling property.</param> - private void RaisePropertyChanging(string propertyName) + protected void RaisePropertyChanging(string propertyName) => PropertyChanging?.Invoke(this, new(propertyName)); /// <summary> /// Raises the <see cref="PropertyChanging"/> event. /// </summary> + /// <typeparam name="T">The type to work with.</typeparam> /// <param name="propertyName">The name of the calling property.</param> /// <param name="value">The value of the calling property.</param> - private void RaisePropertyChanging<T>(string propertyName, T value) + protected void RaisePropertyChanging<T>(string propertyName, T value) => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs<T>(propertyName, value)); /// <summary>