Class AuditContextAccessor
AsyncLocal<T>-backed implementation. Registered as a singleton — the flow, not the instance, carries the value.
public sealed class AuditContextAccessor : IAuditContextAccessor
- Inheritance
-
AuditContextAccessor
- Implements
- Inherited Members
Remarks
An audited call reaches AuditHelper.BuildEntry through several layers (the enforcement proxies,
each auditing decorator), and threading an actor through every signature would put a parameter nobody
on the HTTP path needs into all of them. Ambient context is what AsyncLocal<T> exists
for, and it flows across await without cooperation from the code in between.
The value is static because the flow is the scope. A leaked or wrongly-restored scope would attribute one job's actions to another — the same class of false attribution this feature removes, so Push(AuditActor) always restores the previous value rather than clearing it.
Properties
Current
The actor in effect for the current async flow, or null.
public AuditActor Current { get; }
Property Value
Methods
Push(AuditActor)
Makes actor the actor for the current async flow until the returned scope is
disposed, then restores whatever was in effect before.
public IDisposable Push(AuditActor actor)
Parameters
actorAuditActor