Class PropertyAccessor
- Namespace
- Stratara.Shared.Reflections
- Assembly
- Stratara.Shared.dll
Reflection-backed value accessor for a single property on a declaring type. Compiles strongly-typed getter / setter delegates via PropertyAccessorCache and exposes them through untyped GetValue(object) / SetValue(object, object?) methods that take any instance of the declaring type as boxed object.
public sealed class PropertyAccessor
- Inheritance
-
PropertyAccessor
- Inherited Members
- Extension Methods
Remarks
If the underlying property is read-only, SetValue(object, object?) is a no-op rather than throwing — the caller is responsible for honouring CanWrite if assignment must be observable.
Constructors
PropertyAccessor(PropertyInfo, Type)
Initializes a new accessor for property declared on declaringType.
public PropertyAccessor(PropertyInfo property, Type declaringType)
Parameters
propertyPropertyInfoThe property to wrap.
declaringTypeTypeThe CLR type that declares
property.
Properties
Name
Name of the wrapped property.
public string Name { get; }
Property Value
PropertyType
CLR type of the wrapped property's value.
public Type PropertyType { get; }
Property Value
Methods
GetValue(object)
Reads the property's value from instance.
public object? GetValue(object instance)
Parameters
instanceobjectAn instance of the declaring type.
Returns
SetValue(object, object?)
Writes value into the property on instance. No-op if
the property is read-only.
public void SetValue(object instance, object? value)