MemberPath

Reads and writes a dotted a.b.c member path on an object graph by reflection.

Public Methods

Read

public static object? Read(object? root, string path)

Reads path starting at root, or null if any step is missing.

Parameters:

  • root (object?): The object the path is relative to.
  • path (string): A dotted member path; an empty path returns root.

Returns: object?

TryWrite

public static bool TryWrite(object? root, string path, object? value)

Writes value to the last segment of path.

Parameters:

  • root (object?): The object the path is relative to.
  • path (string): A dotted member path with at least one segment.
  • value (object?): The value to assign; converted to the target member type when possible.

Returns: bool

  • true when the assignment succeeded.