Skip to content

Interface IValueSource

Definition

Namespace: StardewUI.Framework.Sources
Assembly: StardewUI.dll

Holds the type-independent data of an IValueSource<T>.

public interface IValueSource

Remarks

Instances of this type should always implement IValueSource<T> as well; the non-generic version is used when the type is unknown at compile time.

Members

Properties

Name Description
CanRead Whether or not the source can be read from, i.e. if an attempt to get the Value should succeed.
CanWrite Whether or not the source can be written back to, i.e. if an attempt to set the Value should succeed.
DisplayName Descriptive name for the property, used primarily for debug views and log/exception messages.
Value Gets or sets the value as a boxed object. The type must be assignable to/from the type parameter of the IValueSource<T> that this instance implements.
ValueType The compile-time type of the value tracked by this source; the type parameter for IValueSource<T>.

Methods

Name Description
Update(Boolean) Checks if the value needs updating, and if so, updates Value to the latest.

Details

Properties

CanRead

Whether or not the source can be read from, i.e. if an attempt to get the Value should succeed.

bool CanRead { get; }
Property Value

Boolean


CanWrite

Whether or not the source can be written back to, i.e. if an attempt to set the Value should succeed.

bool CanWrite { get; }
Property Value

Boolean


DisplayName

Descriptive name for the property, used primarily for debug views and log/exception messages.

string DisplayName { get; }
Property Value

string


Value

Gets or sets the value as a boxed object. The type must be assignable to/from the type parameter of the IValueSource<T> that this instance implements.

System.Object Value { get; set; }
Property Value

Object


ValueType

The compile-time type of the value tracked by this source; the type parameter for IValueSource<T>.

System.Type ValueType { get; }
Property Value

Type


Methods

Update(bool)

Checks if the value needs updating, and if so, updates Value to the latest.

bool Update(bool force);
Parameters

force   Boolean
If true, forces the source to update its value even if it isn't considered dirty. This should never be used in a regular binding, but can be useful in sources that are intended for occasional or one-shot use such as event handler arguments.

Returns

Boolean

true if the Value was updated; false if it already held the most recent value.

Remarks

This method is called every frame, for every binding, and providing a correct return value is essential in order to avoid slowdowns due to unnecessary rebinds.