Interface IPropertyReference
Represents a reference to a property, providing metadata and access methods for getting, setting, and clearing the property value.
public interface IPropertyReference
- Extension Methods
Properties
Category
Gets the name of the category for the referenced property.
string Category { get; }
Property Value
Metadata
Gets the metadata for the referenced property.
PropertyMetadata Metadata { get; }
Property Value
Remarks
This property provides access to additional information about the property, such as its attributes, default value, and other characteristics that may be relevant for reflection or property manipulation.
Name
Gets the name of the referenced property.
string Name { get; }
Property Value
OwnerType
Gets the owner type of the referenced property.
Type OwnerType { get; }
Property Value
PropertyType
Gets the type of the referenced property value.
Type PropertyType { get; }
Property Value
ValidationCallback
Gets the registered callback for validating the value of the property reference.
ValidateValueCallback? ValidationCallback { get; }
Property Value
Remarks
This property returns null for properties that do not have any validation methods registered.
The validation callback should be invoked before setting a value to the property reference to ensure that the value is valid. Note that these validation callbacks are not called during property access; they are specifically intended for validating values set through property references.
Methods
ClearLocalValue(object)
Clears a directly-assigned (local) value on target, if one is currently in effect,
letting the highest active precedence tier (or the pre-tier fallback value) take over again.
void ClearLocalValue(object target)
Parameters
targetobjectThe object to clear the local value on.
ClearTierValue(object, PropertyValuePrecedence)
Clears the value previously contributed by a non-local precedence tier for
target, and re-applies whichever tier now wins.
void ClearTierValue(object target, PropertyValuePrecedence tier)
Parameters
targetobjectThe object to clear the tiered value on.
tierPropertyValuePrecedenceThe precedence tier whose contribution should be removed.
GetRawValue(object)
Gets the value of the referenced property from the specified target object as an untyped object.
object? GetRawValue(object target)
Parameters
targetobjectThe object from which to retrieve the property value.
Returns
- object
The value of the referenced property as an object.
NotifyLocalValueChanged(object)
Notifies the property reference that its value on target was just changed
through a means other than SetTierValue(object, PropertyValuePrecedence, object?)
(i.e. a direct, local assignment).
void NotifyLocalValueChanged(object target)
Parameters
targetobjectThe object whose property value changed.
Remarks
Marks the newly-observed value as the current local value, which always outranks every precedence tier
(see SetTierValue(object, PropertyValuePrecedence, object?)) — including ones applied
later — until ClearLocalValue(object) is called. This is also the value tiers fall back
to once they're all cleared. Call sites that always fire on every property change (e.g. a
PropertyChanged hook) can call this unconditionally: a target that's never had a tier or a local
assignment applied has no bookkeeping to create here beyond a single lazily-allocated entry.
RawClearValue(object)
Clears the value of the referenced property on the specified target object.
void RawClearValue(object target)
Parameters
targetobjectThe object from which to clear the property value.
Remarks
This method assumes that the DefaultValue for the Metadata contains value possible to assign to the referenced property.
This method removes the value of the property for the given instance of the owner type, effectively resetting it to its default state.
SetRawValue(object, object?)
Sets the value of the referenced property on the specified target from an untyped object.
void SetRawValue(object target, object? value)
Parameters
targetobjectThe object on which to set the property value.
valueobjectThe new value to assign to the property as an object.
SetTierValue(object, PropertyValuePrecedence, object?)
Sets the value contributed by a non-local precedence tier for target,
and re-applies whichever tier currently wins.
void SetTierValue(object target, PropertyValuePrecedence tier, object? value)
Parameters
targetobjectThe object to set the tiered value on.
tierPropertyValuePrecedenceThe precedence tier contributing
value.valueobjectThe value contributed by
tier.
Remarks
A directly-assigned (local) value always outranks every tier here; setting a tier's value never
overrides a local value already in effect for target.