AyCode.Core/AyCode.Models.Server/DynamicMethods
Loretta 03d606164c Overhaul SignalR/DataSource docs, update all references
- Added SIGNALR.md (transport) and SIGNALR_DATASOURCE.md (collection) as layered, comprehensive documentation; retired SIGNALR_ARCHITECTURE.md
- Updated all .md files and READMEs to reference new docs and clarify separation between transport and DataSource
- Clarified CRUD tag structure (5 independent tags), single-method tag-based dispatch, and JSON-in-Binary tech debt
- Added slot allocation and wire format clarifications to serialization docs
- Improved documentation layering, conventions, and critical warnings for future maintainers
2026-03-29 18:28:52 +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 Overhaul SignalR/DataSource docs, update all references 2026-03-29 18:28:52 +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.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.