Files
jdescopingtool/NEW/src/Utils/JdeScoping.SecureStoreManager/ViewModels/ViewModelBase.cs
T
Joseph Doherty d49330e697 docs: add XML documentation and ConfigManager implementation plans
Add comprehensive XML documentation (param/returns tags) across 132 source
files to improve IntelliSense and API discoverability. Include ConfigManager
design documents and implementation plans for phases 1-9.
2026-01-20 02:26:26 -05:00

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;
}
}