Skip to content

Class DirtyTracker<T>

Definition

Namespace: StardewUI.Layout
Assembly: StardewUI.dll

Convenience class for tracking properties that have changed, i.e. for layout dirty checking.

public class DirtyTracker<T>

Type Parameters

T
Type of value held by the tracker.

Inheritance
Object ⇦ DirtyTracker<T>

Remarks

Will not flag changes as dirty unless the changed value is different from previous. Requires a correct Equals(Object) implementation for this to work, typically meaning strings, primitives and records.

Members

Constructors

Name Description
DirtyTracker<T>(T) Convenience class for tracking properties that have changed, i.e. for layout dirty checking.

Properties

Name Description
IsDirty Whether or not the value is dirty, i.e. has changed since the last call to ResetDirty().
Value The currently-held value.

Methods

Name Description
ResetDirty() Resets the dirty flag, so that IsDirty returns false until the Value is changed again.
SetIfChanged(T) Updates the tracker with a new value, if it has changed since the last seen value.

Details

Constructors

DirtyTracker<T>(T)

Convenience class for tracking properties that have changed, i.e. for layout dirty checking.

public DirtyTracker<T>(T initialValue);
Parameters

initialValue   T
Value to initialize with.

Remarks

Will not flag changes as dirty unless the changed value is different from previous. Requires a correct Equals(Object) implementation for this to work, typically meaning strings, primitives and records.


Properties

IsDirty

Whether or not the value is dirty, i.e. has changed since the last call to ResetDirty().

public bool IsDirty { get; private set; }
Property Value

Boolean


Value

The currently-held value.

public T Value { get; set; }
Property Value

T


Methods

ResetDirty()

Resets the dirty flag, so that IsDirty returns false until the Value is changed again.

public void ResetDirty();

SetIfChanged(T)

Updates the tracker with a new value, if it has changed since the last seen value.

public bool SetIfChanged(T value);
Parameters

value   T
The new value.

Returns

Boolean

true if the value was different from the previous Value, otherwise false.

Remarks

If this method returns true, then IsDirty will always also be true afterward. However, if it returns false then the dirty state simply remains unchanged, and will only be false if the value was not already dirty from a previous change.