/
hlebusheck
/
notes
Обзор
Документация
Войти
/
hlebusheck
/
notes
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
localization
Notes.Model/Base/NotifyEntity.cs
29 строк
970 B
Hlebusheck
NET 8
16 апр 2024, 19:11
16 апр 2024, 19:11
8638cf1
Код
Авторство
О чём код?
using System.ComponentModel; using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.CompilerServices; using System.Text.Json.Serialization; namespace Notes.Model.Base { public class NotifyEntity : Entity, INotifyEntity { public event PropertyChangedEventHandler? PropertyChanged; [NotMapped, JsonIgnore] public bool NotifyChanges { get; set; } = true; protected void OnPropertyChanged(string? propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); protected override bool SetValue<T>(ref T property, T value, Action<T>? action, [CallerMemberName] string? propertyName = null) { if (base.SetValue(ref property, value, action, propertyName)) { if(NotifyChanges) OnPropertyChanged(propertyName); return true; } return false; } } }