1e21e33ade
Move SecureStoreManager project and tests to Deprecated folder and remove from solution. SecureStore functionality is now integrated into ConfigManager.
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace JdeScoping.SecureStoreManager.ViewModels;
|
|
|
|
/// <summary>
|
|
/// Base class for all view models providing INotifyPropertyChanged implementation.
|
|
/// </summary>
|
|
public abstract class ViewModelBase : INotifyPropertyChanged
|
|
{
|
|
/// <summary>Occurs when a property value changes.</summary>
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
/// <summary>
|
|
/// Raises the PropertyChanged event for the specified property.
|
|
/// </summary>
|
|
/// <param name="propertyName">The name of the property that changed.</param>
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets a property value and raises PropertyChanged if the value changed.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the property.</typeparam>
|
|
/// <param name="field">Reference to the backing field.</param>
|
|
/// <param name="value">The new value.</param>
|
|
/// <param name="propertyName">The name of the property.</param>
|
|
/// <returns>True if the value changed, false otherwise.</returns>
|
|
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(field, value))
|
|
return false;
|
|
|
|
field = value;
|
|
OnPropertyChanged(propertyName);
|
|
return true;
|
|
}
|
|
}
|