AyCode.Core/AyCode.Models.Server/DynamicMethods
Loretta 0b27532f17 Document SignalR architecture, grid, and ext deps
Added comprehensive docs for SignalR tag-based dispatch (docs/SIGNALR_ARCHITECTURE.md), including message flow, tag system, dynamic method registry, and tech debt (JSON-in-Binary). Updated all related READMEs, glossaries, and conventions to reference this architecture and clarify grid infrastructure (MgGridBase, FruitBankGridBase) and external dependency locations (AyCode.Core, AyCode.Blazor, Mango.Nop Libraries, FruitBank Plugin). Synchronized solution items and copilot-instructions. Improves discoverability, enforces conventions, and clarifies tech debt for all developers.
2026-03-29 10:43:07 +02:00
..
AcDynamicMethodCallModel.cs Refactor SignalR dynamic method lookup with static registry 2026-01-02 15:51:50 +01:00
AcDynamicMethodRegistry.cs Refactor SignalR dynamic method lookup with static registry 2026-01-02 15:51:50 +01:00
AcMethodInfoModel.cs Add SignalR common services and dependencies 2025-08-31 12:39:47 +02:00
README.md Document SignalR architecture, grid, and ext deps 2026-03-29 10:43:07 +02:00

README.md

DynamicMethods

Reflection-based infrastructure for dynamically dispatching method calls by message tag, primarily used for SignalR message routing.

Context: This is the server-side dispatch engine for the SignalR tag-based architecture. See docs/SIGNALR_ARCHITECTURE.md for the full message flow.

How It Fits

When AcWebSignalRHubBase.OnReceiveMessage(tag, bytes, requestId) is called, the hub uses DynamicMethodRegistry to resolve which method to invoke for the given tag. The registry scans all registered service instances for [SignalR(tag)] attributed methods, caches the lookup, and invokes the matching method with deserialized parameters.

Caching Strategy

  • Per-type cache: AcDynamicMethodCallModel builds a FrozenDictionary<int, AcMethodInfoModel> once per service type. Immutable after creation.
  • Global cache: AcDynamicMethodRegistry maintains a ConcurrentDictionary<int, AcMethodInfoModel> populated lazily per tag on first request.
  • Instance tracking: The registry maps tags to owning instances for correct invocation context.

Key Files

  • AcMethodInfoModel.cs — Wraps a MethodInfo and its TagAttribute with cached parameter metadata (ParamInfos[] for deserialization).
  • AcDynamicMethodCallModel.cs — Binds an object instance to its attributed methods, using a static ConcurrentDictionary and FrozenDictionary cache keyed by message tag. Reflection runs once per type.
  • AcDynamicMethodRegistry.cs — Registry with lazy method lookup across multiple registered instances. Caches discovered methods statically by message tag and resolves instances per request.