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

1.4 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.

LLM Maintenance: If you modify code in this folder, update this README to reflect the changes. If you notice the README content does not match the current code, automatically update the README to match the code.