The recording of the first ever ReactiveUI virtual conference is available on our YouTube Channel.

Reflection.

TrySetValueToPropertyChain<TValue>(object?, IEnumerable<Expression>, TValue, bool) Method

Summary

Based on a list of Expressions set a value of the last property in the chain if possible. The Expressions are property chains. Eg Property1.Property2.Property3 The method will make sure that each Expression can use each value along the way and set the last value.
Namespace
ReactiveUI
Containing Type
Reflection

Syntax

public static bool TrySetValueToPropertyChain<TValue>(object? target, IEnumerable<Expression> expressionChain, TValue value, bool shouldThrow = true)

Type Parameters

Name Description
TValue The type of the end value we are trying to set.

Parameters

Name Type Description
target object? The object that starts the property chain.
expressionChain IEnumerable<Expression> A list of expressions which will point towards a property or field.
value TValue The value to set on the last property in the Expression chain.
shouldThrow bool If we should throw if we are unable to set the value.

Return Value

Type Description
bool If the value was successfully retrieved or not.