Skip to main content
Table of Contents

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

property PropertyInfo

The property to wrap.

declaringType Type

The CLR type that declares property.

Properties

Name

Name of the wrapped property.

public string Name { get; }

Property Value

string

PropertyType

CLR type of the wrapped property's value.

public Type PropertyType { get; }

Property Value

Type

Methods

GetValue(object)

Reads the property's value from instance.

public object? GetValue(object instance)

Parameters

instance object

An instance of the declaring type.

Returns

object

The current property value, boxed as object.

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)

Parameters

instance object

An instance of the declaring type.

value object

The new property value, boxed as object.