Table of Contents

Class DynamicPropertyDescriptor

Namespace
Bonsai.Design
Assembly
Bonsai.Design.dll

Provides a virtual property for a class.

public class DynamicPropertyDescriptor : PropertyDescriptor
Inheritance
DynamicPropertyDescriptor
Inherited Members

Constructors

DynamicPropertyDescriptor(string, Type, Func<object, object>, Action<object, object>, params Attribute[])

Initializes a new instance of the DynamicPropertyDescriptor class using the specified name, type, and dynamic methods for getting and setting property values.

public DynamicPropertyDescriptor(string name, Type type, Func<object, object> getter, Action<object, object> setter, params Attribute[] attributes)

Parameters

name string

The name of the dynamic property.

type Type

The type of the dynamic property.

getter Func<object, object>

A method used to get the current value of the dynamic property.

setter Action<object, object>

A method used to set the value of the dynamic property to a different value.

attributes Attribute[]

An optional array of Attribute objects that contains the property attributes.

Properties

ComponentType

Gets the type of the component this property is bound to.

public override Type ComponentType { get; }

Property Value

Type

IsReadOnly

Gets a value indicating whether this property is read-only.

public override bool IsReadOnly { get; }

Property Value

bool

PropertyType

Gets the type of the dynamic property.

public override Type PropertyType { get; }

Property Value

Type

Methods

CanResetValue(object)

Returns whether resetting an object changes its value. Dynamic properties do not support resetting, so resetting an object never changes its value.

public override bool CanResetValue(object component)

Parameters

component object

The component to test for reset capability.

Returns

bool

true if resetting the component changes its value; otherwise, false.

GetValue(object)

Gets the current value of the property on a component.

public override object GetValue(object component)

Parameters

component object

The component with the property for which to retrieve the value.

Returns

object

The value of a property for a given component.

ResetValue(object)

Resets the value for this property of the component to the default value. Dynamic properties do not support resetting their values.

public override void ResetValue(object component)

Parameters

component object

The component with the property value that is to be reset to the default value.

SetValue(object, object)

Sets the value of the dynamic property to a different value.

public override void SetValue(object component, object value)

Parameters

component object

The component with the property value that is to be set.

value object

The new value.

ShouldSerializeValue(object)

Determines a value indicating whether the value of this property needs to be persisted. Dynamic property values are transient, so they always need to be persisted.

public override bool ShouldSerializeValue(object component)

Parameters

component object

The component with the property to be examined for persistence.

Returns

bool

true if the property should be persisted; otherwise, false.