Class LazyExpressionFieldDescriptor<TValue>
Definition
Namespace: StardewUI.Framework.Descriptors
Assembly: StardewUI.dll
Implementation of a field descriptor that supports a transition between two inner descriptor types.
public class LazyExpressionFieldDescriptor<TValue> :
StardewUI.Framework.Descriptors.IPropertyDescriptor<TValue>,
StardewUI.Framework.Descriptors.IPropertyDescriptor,
StardewUI.Framework.Descriptors.IMemberDescriptor
Type Parameters
TValue
The field's value type.
Inheritance
Object ⇦ LazyExpressionFieldDescriptor<TValue>
Implements
IPropertyDescriptor<TValue>, IPropertyDescriptor, IMemberDescriptor
Remarks
Designed to initially use a "slow" descriptor that is poorly optimized for access times, but is available immediately, and then transition to a "fast" descriptor that is created asynchronously and slowly, but is better optimized for frequent access.
Members
Constructors
Name | Description |
---|---|
LazyExpressionFieldDescriptor<TValue>(IPropertyDescriptor<TValue>, Task<IPropertyDescriptor<TValue>>) | Initializes a new LazyExpressionFieldDescriptor<TValue> instance. |
Properties
Name | Description |
---|---|
CanRead | Whether or not the property is readable, i.e. has a public getter. |
CanWrite | Whether or not the property is writable, i.e. has a public setter. |
DeclaringType | The type on which the member is declared. |
IsAutoProperty | Whether or not the property is likely auto-implemented. |
IsField | Whether or not the underlying member is a field, rather than a real property. |
Name | The member name. |
ValueType | The property's value type. |
Methods
Name | Description |
---|---|
GetValue(Object) | Reads the current property value. |
SetValue(Object, TValue) | Writes a new property value. |
Details
Constructors
LazyExpressionFieldDescriptor<TValue>(IPropertyDescriptor<TValue>, Task<IPropertyDescriptor<TValue>>)
Initializes a new LazyExpressionFieldDescriptor<TValue> instance.
public LazyExpressionFieldDescriptor<TValue>(StardewUI.Framework.Descriptors.IPropertyDescriptor<TValue> slowDescriptor, System.Threading.Tasks.Task<StardewUI.Framework.Descriptors.IPropertyDescriptor<TValue>> fastDescriptorTask);
Parameters
slowDescriptor
IPropertyDescriptor<TValue>
The slower but immediately-available descriptor to use initially; typically an instance of ReflectionFieldDescriptor<TValue>.
fastDescriptorTask
Task<IPropertyDescriptor<TValue>>
The faster, deferred descriptor to use once available; typically an instance of ExpressionFieldDescriptor<T, TValue>.
Properties
CanRead
Whether or not the property is readable, i.e. has a public getter.
Property Value
Remarks
For fields, always returns true
.
CanWrite
Whether or not the property is writable, i.e. has a public setter.
Property Value
DeclaringType
The type on which the member is declared.
Property Value
IsAutoProperty
Whether or not the property is likely auto-implemented.
Property Value
Remarks
Auto-property detection is heuristic, relying on the method's IL instructions and the name of its backing field. This can often be interpreted as a signal that the property won't receive property-change notifications, since to do so (whether explicitly or via some weaver/source generator) requires an implementation that is different from the auto-generated getter and setter.
Caveats: This only works as a negative signal (a value of false
does not prove that the property will receive notifications, even if the declaring type implements INotifyPropertyChanged), and is somewhat fuzzy even as a negative signal; it is theoretically possible for a source generator or IL weaver to leave behind all the markers of an auto property and still emit notifications, although no known libraries actually do so.
IsField
Whether or not the underlying member is a field, rather than a real property.
Property Value
Remarks
For binding convenience, fields and properties are both called "properties" for descriptors, as the external access pattern is the same; however, mutable fields can never reliably emit property-change notifications regardless of whether the declaring type implements INotifyPropertyChanged, so this is usually used to emit some warning.
Name
The member name.
Property Value
ValueType
The property's value type.
Property Value
Methods
GetValue(Object)
Reads the current property value.
Parameters
source
Object
An instance of the property's DeclaringType.
Returns
TValue
SetValue(Object, TValue)
Writes a new property value.
Parameters
target
Object
An instance of the property's DeclaringType.
value
TValue
The new property value.