EasyObservableObject

A base class for objects to implement . Provides strongly-typed property change notifications and automatic property setting with change detection.

Syntax

public class EasyObservableObject : INotifyPropertyChanged, IDisposable

Inheritance

Implements

Constructors

EasyObservableObject

public EasyObservableObject()
Initializes a new instance of the class.

Properties

PropertyChangedHandler

protected PropertyChangedEventHandler PropertyChangedHandler { get; }
Provides access to the PropertyChanged event handler to derived classes.

Returns

PropertyChangedEventHandler

Methods

Clone<T>

public T Clone<T>() where T : EasyObservableObject
Creates a deep copy of the current object using JSON serialization.

Returns

T A new instance of type T that is a deep copy of the current object.

Exceptions

  • [JsonException](https://learn.microsoft.com/dotnet/api/system.text.json.jsonexception): Thrown when the object cannot be serialized or deserialized.

Dispose

public void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Dispose

protected virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the and optionally releases the managed resources.

Parameters

  • disposing bool: true to release both managed and unmanaged resources; false to release only unmanaged resources.

RaisePropertyChanged

protected virtual void RaisePropertyChanged(string propertyName = null)
Raises the PropertyChanged event if needed.

Parameters

  • propertyName string: The name of the property that changed.

RaisePropertyChanged<T>

protected virtual void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
Raises the PropertyChanged event if needed.

Parameters

Set<T>

protected void Set<T>(Expression<Func<T>> propertyExpression, ref T field, T newValue)
Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

Parameters

  • propertyExpression Expression<Func<T>>: An expression identifying the property that changed.
  • field T: The field storing the property’s value.
  • newValue T: The property’s value after the change occurred.

Set<T>

protected virtual void Set<T>(string propertyName, ref T field, T newValue)
Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

Parameters

  • propertyName string: The name of the property that changed.
  • field T: The field storing the property’s value.
  • newValue T: The property’s value after the change occurred.

Events

PropertyChanged

public event PropertyChangedEventHandler PropertyChanged
Occurs when a property value changes.

Returns

PropertyChangedEventHandler