Class TrackableObject<T>
- Namespace
- RadioExt_Helper.models
- Assembly
- RadioExt-Helper.dll
Represents a trackable object that implements the ITrackable interface.
This class can track changes made to the object and determines if there are pending changes to its properties.
The object must have public properties in order to be tracked.
If the tracked object contains non-primitive objects that also need to be tracked independently of the parent, the tracked object, TrackedObject and all children need to implement INotifyPropertyChanged as well as ICloneable and IEquatable<T>.
public sealed class TrackableObject<T> : INotifyPropertyChanged, ITrackable where T : class, INotifyPropertyChanged, new()
Type Parameters
T
- The type of the object being tracked.
- Inheritance
-
TrackableObject<T>
- Implements
- Inherited Members
Constructors
TrackableObject(T)
Initializes a new instance of the TrackableObject<T> class.
public TrackableObject(T obj)
Parameters
obj
T- The object to be tracked.
Properties
Id
Get a unique identifier for the tracked object.
public Guid Id { get; }
Property Value
IsPendingSave
Gets a value indicating whether the object has pending changes.
public bool IsPendingSave { get; }
Property Value
TrackedObject
Gets the tracked object.
public T TrackedObject { get; }
Property Value
- T
Methods
AcceptChanges()
Accepts the changes made to the tracked object and marks it as not pending save.
Accepting the changes will update the original values with the changed ones.
public void AcceptChanges()
CheckPendingSaveStatus()
Checks the pending save status of the tracked object.
public bool CheckPendingSaveStatus()
Returns
- bool
- True if there are pending changes, otherwise false.
DeclineChanges()
Reverts the changes made to the tracked object and marks it as not pending save.
public void DeclineChanges()
ToString()
Returns a string that represents the tracked object.
public override string ToString()
Returns
- string
- A string that represents the tracked object.
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler? PropertyChanged