Struct RetentionScope
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Where a personal-data value sits, for the purpose of deciding which key protects it: the aggregate type it is stored inside.
public readonly struct RetentionScope : IEquatable<RetentionScope>
- Implements
- Inherited Members
Remarks
A scope is a VALUE, never an absence. It is exactly one of NotInAnAggregate or For(string), so "not stored inside an aggregate" and "the caller did not know" cannot arrive as the same thing. A nullable string carried three meanings that resolved identically — and resolved toward destruction, which is the direction that cannot be walked back.
It is a distinct type for a second reason. Both of its parts are strings, and so is the data subject identifier they travel beside. Passed as bare strings, transposing two of them compiles, runs, and encrypts every subject's data under one shared handle — a mistake no diagnostic at any tier would report. A scope cannot be passed where an identifier is expected.
The unit is the aggregate type, whole, and that is a legal fact rather than a simplification. An obligation to keep a record attaches to the RECORD. A statute requiring sales records to be kept does not require the buyer and permit deleting the salesperson — a partly-erased record is a MUTATED record, and a mutated record has no evidentiary value, which is the entire reason for keeping it. So every data subject named in a retained aggregate type is covered by that record's obligation.
Properties
AggregateType
Gets the aggregate type the value is stored inside.
public string? AggregateType { get; }
Property Value
IsInAnAggregate
Gets a value indicating whether this scope names an aggregate.
public bool IsInAnAggregate { get; }
Property Value
NotInAnAggregate
Gets the scope for a value that is not stored inside an aggregate.
public static RetentionScope NotInAnAggregate { get; }
Property Value
- RetentionScope
The scope carrying no aggregate type.
Remarks
The default, so a value reaching the key manager without a deliberate scope resolves to the data subject's own key — the key an erasure destroys — rather than to one it would not reach.
Methods
Equals(RetentionScope)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(RetentionScope other)
Parameters
otherRetentionScopeAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
For(string)
Creates the scope for a value stored inside an aggregate.
public static RetentionScope For(string aggregateType)
Parameters
aggregateTypestringThe aggregate type, as the event store records it.
Returns
- RetentionScope
The scope naming that aggregate type.
Exceptions
- ArgumentException
Thrown when the argument is null, empty or whitespace.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns a diagnostic description of the scope.
public override string ToString()
Returns
- string
The aggregate type, or a marker for the unscoped case.
Operators
operator ==(RetentionScope, RetentionScope)
Compares two scopes for equality.
public static bool operator ==(RetentionScope left, RetentionScope right)
Parameters
leftRetentionScopeThe left scope.
rightRetentionScopeThe right scope.
Returns
operator !=(RetentionScope, RetentionScope)
Compares two scopes for inequality.
public static bool operator !=(RetentionScope left, RetentionScope right)
Parameters
leftRetentionScopeThe left scope.
rightRetentionScopeThe right scope.