AyCode.Blazor/AyCode.Blazor.Components/Services/ExpressionHelpers/README.md

1.2 KiB

ExpressionHelpers

LINQ expression tree serialization and deserialization to JSON, enabling expression transport over SignalR or HTTP. Converts Expression trees to a recursive AcExpressionNode DTO and back, supporting binary, unary, lambda, member access, method calls, conditionals, new/member-init, and array expressions.

Key Files

  • AcExpressionNode.cs -- Universal DTO representing any expression node. Includes ParameterNode and MemberBindingNode supporting types. Recursively models the full expression tree and is JSON-serializable.
  • AcExpressionHelper.cs -- Static facade for serializing/deserializing expressions and IQueryable query trees. Provides ExpressionToJson, ExpressionFromJson, QueryToJson, and ApplyQueryFromJson methods.
  • AcExpressionSerializerVisitor.cs -- ExpressionVisitor subclass that walks an expression tree and builds the AcExpressionNode graph using a stack-based approach. Handles closure variable evaluation and constant serialization.
  • AcExpressionDeserializer.cs -- Reconstructs Expression trees from AcExpressionNode DTOs. Resolves types, parameters, methods, and member bindings. Handles nullable type mismatches in binary expressions.