EyeAuras Docs EyeAuras Docs
EyeAuras Docs EyeAuras Docs
DocFX + Singulink = ♥

Search Results for

    Method ParseBindingExpression

    ParseBindingExpression<T>(Expression<Func<T>>)

    Parses an expression representing access to a nested property and returns two components:

    1. A lambda expression that evaluates the root object involved in the property chain.
    2. A string representing the property path relative to that root object (excluding the root itself).
    Declaration
    public static (Expression<Func<object>> rootExpression, string propertyPath) ParseBindingExpression<T>(Expression<Func<T>> targetProperty)
    Parameters
    Type Name Description
    Expression<Func<T>> targetProperty

    An expression representing the property access to be parsed. For example: () => DataContext.Mouse.X

    Returns
    Type Description
    (Expression<Func<object>> rootExpression, string propertyPath)

    A tuple containing:

    • rootExpression: a lambda expression that returns the root object (e.g., DataContext).
    • propertyPath: a string representing the dot-separated property path relative to the root (e.g., Mouse.X).
    Type Parameters
    Name Description
    T

    The type of the final property being accessed in the expression chain.

    Examples

    Suppose you have the following object hierarchy:

    public class AppModel {
        public MouseState Mouse { get; set; }
    }
    
    public class MouseState {
        public int X { get; set; }
        public int Y { get; set; }
    }
    
    AppModel DataContext = new AppModel {
        Mouse = new MouseState { X = 100, Y = 200 }
    };

    And you call:

    var (rootExpr, path) = ParseExpression(() => DataContext.Mouse.X);

    Then:

    • rootExpr() will evaluate to DataContext
    • path will be "Mouse.X"
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the expression structure is unsupported, such as:

    • a constant expression with no parent,
    • a property chain that doesn't contain at least two member expressions,
    • or an unknown expression type that cannot be resolved.
    2025 © Xab3r. All rights reserved.