Class ContextPathValueSource<T>
Definition
Namespace: StardewUI.Framework.Sources
Assembly: StardewUI.dll
Value source that obtains its value from a property path, starting from some root data and traversing the list of properties to reach the final value.
public class ContextPathValueSource<T> :
StardewUI.Framework.Sources.IValueSource<T>,
StardewUI.Framework.Sources.IValueSource, System.IDisposable
Type Parameters
T
The return type of the context property, i.e. at the end of the path.
Inheritance
Object ⇦ ContextPathValueSource<T>
Implements
IValueSource<T>, IValueSource, IDisposable
Members
Constructors
| Name | Description |
|---|---|
| ContextPathValueSource<T>(BindingContext, IPropertyDescriptor, Boolean) | Initializes a new ContextPathValueSource<T> using the specified context and property sequence. |
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 | |
| ValueType | The compile-time type of the value tracked by this source; the type parameter for IValueSource<T>. |
Methods
| Name | Description |
|---|---|
| Dispose() | |
| Update(Boolean) | Checks if the value needs updating, and if so, updates Value to the latest. |
Details
Constructors
ContextPathValueSource<T>(BindingContext, IPropertyDescriptor, bool)
Initializes a new ContextPathValueSource<T> using the specified context and property sequence.
public ContextPathValueSource<T>(StardewUI.Framework.Binding.BindingContext context, StardewUI.Framework.Descriptors.IPropertyDescriptor properties, bool allowUpdates);
Parameters
context BindingContext
Context used for the data binding.
properties IPropertyDescriptor
Array of properties to traverse, in order. Equivalent to a nested C# accessor expression such as "Foo.Bar.Baz".
allowUpdates Boolean
Whether or not to allow Update(Boolean) to read a new value. false prevents all updates and makes the source read only one time.
Properties
CanRead
Whether or not the source can be read from, i.e. if an attempt to get the Value should succeed.
Property Value
CanWrite
Whether or not the source can be written back to, i.e. if an attempt to set the Value should succeed.
Property Value
DisplayName
Descriptive name for the property, used primarily for debug views and log/exception messages.
Property Value
Value
Property Value
T
ValueType
The compile-time type of the value tracked by this source; the type parameter for IValueSource<T>.
Property Value
Methods
Dispose()
Update(bool)
Checks if the value needs updating, and if so, updates Value to the latest.
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
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.