. | using Newtonsoft.Json; |
| |
| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using System.ComponentModel; |
| using System.ComponentModel; |
| using System.Linq; |
| using System.Linq; |
| using System.Runtime.CompilerServices; |
| using System.Runtime.CompilerServices; |
| using System.Text; |
| using System.Text; |
| using System.Threading.Tasks; |
| using System.Threading.Tasks; |
| |
| |
| namespace System.Collections.Generic |
| namespace System.Collections.Generic |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Represents object implementing INotifyPropertyChanged. |
| /// Represents object implementing INotifyPropertyChanged. |
| /// </summary> |
| /// </summary> |
| public abstract class ObservableObject : INotifyPropertyChanged |
| public abstract class ObservableObject : INotifyPropertyChanged |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// If set to <c>true</c> no <see cref="PropertyChanged"/> events will be fired. |
| /// If set to <c>true</c> no <see cref="PropertyChanged"/> events will be fired. |
| /// </summary> |
| /// </summary> |
. | [JsonIgnore] |
| internal bool SuppressNotifications |
| public bool SuppressNotifications |
| |
| { |
| { |
| get; set; |
| get; set; |
| } = false; |
| } = false; |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Occurs when a property value changes |
| /// Occurs when a property value changes |
| /// </summary> |
| /// </summary> |
| public event PropertyChangedEventHandler PropertyChanged; |
| public event PropertyChangedEventHandler PropertyChanged; |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Invokes PropertyChanged events. |
| /// Invokes PropertyChanged events. |
| /// </summary> |
| /// </summary> |
| /// <param name="name">Name of property that changed.</param> |
| /// <param name="name">Name of property that changed.</param> |
| public void OnPropertyChanged([CallerMemberName]string name = null) |
| public void OnPropertyChanged([CallerMemberName]string name = null) |
| { |
| { |
| if (!SuppressNotifications) |
| if (!SuppressNotifications) |
| { |
| { |
| PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); |
| PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); |
. | |
| } |
| |
| } |
| |
| |
| |
| /// <summary> |
| |
| /// |
| |
| /// </summary> |
| |
| /// <typeparam name="T"></typeparam> |
| |
| /// <param name="property"></param> |
| |
| /// <param name="value"></param> |
| |
| /// <param name="propertyName"></param> |
| |
| protected void SetValue<T>(ref T property, T value, [CallerMemberName]string propertyName = null) |
| |
| { |
| |
| property = value; |
| |
| OnPropertyChanged(propertyName); |
| |
| } |
| |
| |
| |
| /// <summary> |
| |
| /// |
| |
| /// </summary> |
| |
| /// <typeparam name="T"></typeparam> |
| |
| /// <param name="property"></param> |
| |
| /// <param name="value"></param> |
| |
| /// <param name="propertyNames"></param> |
| |
| protected void SetValue<T>(ref T property, T value, params string[] propertyNames) |
| |
| { |
| |
| property = value; |
| |
| foreach (var pro in propertyNames) |
| |
| { |
| |
| OnPropertyChanged(pro); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |