Replaced Markdown links with plain code-style paths in all README.md files for consistency. Updated references to logging, SignalR, and dynamic method dispatch documentation. Clarified some documentation paths and improved consistency in context/architecture sections. No code changes—documentation only. |
||
|---|---|---|
| .. | ||
| AcDynamicMethodCallModel.cs | ||
| AcDynamicMethodRegistry.cs | ||
| AcMethodInfoModel.cs | ||
| README.md | ||
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_SERVER.mdfor 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:
AcDynamicMethodCallModelbuilds aFrozenDictionary<int, AcMethodInfoModel>once per service type. Immutable after creation. - Global cache:
AcDynamicMethodRegistrymaintains aConcurrentDictionary<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 aMethodInfoand itsTagAttributewith cached parameter metadata (ParamInfos[]for deserialization).AcDynamicMethodCallModel.cs— Binds an object instance to its attributed methods, using a staticConcurrentDictionaryandFrozenDictionarycache 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.