453ec7358d
Code-review fixes: CompositeAuditWriter re-throws OperationCanceledException (honors cancellation) + evt null-guard; RedactingAuditWriter evt null-guard; added marker-longer-than-max and cancellation-propagation regression tests.
25 lines
889 B
C#
25 lines
889 B
C#
namespace ZB.MOM.WW.Audit;
|
|
|
|
/// <summary>Decorator: applies an <see cref="IAuditRedactor"/>, then delegates to an inner <see cref="IAuditWriter"/>.</summary>
|
|
public sealed class RedactingAuditWriter : IAuditWriter
|
|
{
|
|
private readonly IAuditRedactor _redactor;
|
|
private readonly IAuditWriter _inner;
|
|
|
|
/// <summary>Creates the decorator around <paramref name="inner"/> using <paramref name="redactor"/>.</summary>
|
|
public RedactingAuditWriter(IAuditRedactor redactor, IAuditWriter inner)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(redactor);
|
|
ArgumentNullException.ThrowIfNull(inner);
|
|
_redactor = redactor;
|
|
_inner = inner;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Task WriteAsync(AuditEvent evt, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(evt);
|
|
return _inner.WriteAsync(_redactor.Apply(evt), ct);
|
|
}
|
|
}
|