Class ReadModelSubjectResolver

Namespace
Cratis.Chronicle.ReadModels
Assembly
Cratis.Chronicle.dll

Resolves a Subject from a read model instance by checking for a property or constructor parameter decorated with SubjectAttribute that has a value, falling back to a property named Id.

public static class ReadModelSubjectResolver
Inheritance
ReadModelSubjectResolver
Inherited Members

Methods

ResolveFrom(object?)

Attempt to derive a Subject from a read model instance.

Resolution order:

  1. A property decorated with SubjectAttribute that has a value.
  2. A constructor parameter decorated with SubjectAttribute that has a value (record shorthand).
  3. Property named Id (case-insensitive).

An attributed property that is null, empty, or NotSet does not stop resolution; the Id fallback is attempted next.

public static Subject? ResolveFrom(object? instance)

Parameters

instance object

The read model instance to inspect, or null for a read model that does not exist (never created or removed).

Returns

Subject

The resolved Subject, or null when no subject can be derived (including when instance is null).