FieldVariable

Sealed internal Variable implementation that reads and writes a field on an owner object via reflection. Used for variables discovered automatically from [Variable]-attributed fields on Action subclasses.

Definition

Namespace: Paragon.Core.ActionSystem Assembly: Paragon.dll

[Serializable]
internal sealed class FieldVariable : Variable

Inheritance: Variable → FieldVariable

Remarks

FieldVariable provides a live binding to an actual field on the owning Action instance. When GetValue() is called, it reads the field via FieldInfo.GetValue(); when SetValue() is called, it writes via FieldInfo.SetValue(). This means changes made directly to the action's field are immediately visible through the variable, and vice versa.

The FieldInfo is lazily resolved on first access via GetField(), which looks up the field by name using BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic. This lazy resolution handles deserialization scenarios where FieldInfo cannot be persisted.

Field variables are:

  • Created automatically during ActionVariables construction and after deserialization

  • Not removable — they are managed by the reflection discovery system

  • Stored in the fieldVariables dictionary of ActionVariables

Constructor

FieldVariable(object, FieldInfo)

Creates a field variable bound to a specific field on an owner object. The type and name are derived from the FieldInfo.

Parameter
Type
Description

owner

object

The object instance that owns the field (typically an Action)

fieldInfo

FieldInfo

Reflection metadata for the target field

Methods

SetValue

Writes the value to the owner's field via reflection.

Parameter
Type
Description

value

object

The value to assign to the field

GetValue

Reads the current value from the owner's field via reflection.

Returns: The current field value as object.

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated