AyCode.Core/AyCode.Models.Server/DynamicMethods
Loretta affa85e5c5 [LOADED_DOCS: 4 files, no new loads]
Refactor docs: topic folders, TOON, XCUT, protocol sync

- Migrated all topic documentation into dedicated folders with canonical `README.md`, `ISSUES.md`, and `TODO.md` per topic (e.g., `LOGGING/`, `SIGNALR/`, `BINARY/`, `TOON/`).
- Added comprehensive TOON serializer documentation: design, format, options, attributes, inference, issues, and TODOs.
- Introduced `XCUT` folder for cross-cutting issues and TODOs, with canonical entries and topic cross-references.
- Updated all references and navigation to use new folder-based doc paths; fixed links and clarified doc structure.
- Enhanced AI agent protocol: enforce session skill preloading, `[LOADED_DOCS: ...]` short-name prefix, and mandatory `docs-check` skill for doc/code sync.
- Updated `.csproj` to include all `README.md` files for IDE visibility.
- Improved and clarified SignalR, grid, and project-level documentation.
- Minor code/test tweaks and doc content corrections for consistency.
2026-04-24 21:54:04 +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 [LOADED_DOCS: 4 files, no new loads] 2026-04-24 21:54:04 +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 AyCode.Services.Server/docs/SIGNALR/README.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.