Struct CommandDataOwner
The tenant and user a command's protected fields are encrypted for — the one answer every place that serializes or deserializes a command asks for, so that no two of them can disagree.
public readonly record struct CommandDataOwner : IEquatable<CommandDataOwner>
- Implements
- Inherited Members
- Extension Methods
Remarks
A command that implements INamesDataOwner is written for the owner it names, in every copy. A command that does not is written for the session it was dispatched under: the copy carried to a handler for the session's data-owner tenant and acting user, the recorded copy for the session's data-owner tenant and data-owner user.
Constructors
CommandDataOwner(Guid, Guid?, bool)
The tenant and user a command's protected fields are encrypted for — the one answer every place that serializes or deserializes a command asks for, so that no two of them can disagree.
public CommandDataOwner(Guid TenantId, Guid? UserId, bool Named)
Parameters
TenantIdGuidThe tenant the fields are encrypted for.
UserIdGuid?The user the fields are encrypted for, or null.
Namedbooltrue when the command named this owner; false when it was taken from the session.
Remarks
A command that implements INamesDataOwner is written for the owner it names, in every copy. A command that does not is written for the session it was dispatched under: the copy carried to a handler for the session's data-owner tenant and acting user, the recorded copy for the session's data-owner tenant and data-owner user.
Properties
Named
public bool Named { get; init; }
Property Value
NamedTenantId
The tenant a carrier of the command records beside its session: TenantId when the command named its owner, null when the owner was taken from the session.
public Guid? NamedTenantId { get; }
Property Value
- Guid?
NamedUserId
The user a carrier of the command records beside its session: UserId when the command named its owner, null when the owner was taken from the session.
public Guid? NamedUserId { get; }
Property Value
- Guid?
TenantId
The tenant the fields are encrypted for.
public Guid TenantId { get; init; }
Property Value
UserId
The user the fields are encrypted for, or null.
public Guid? UserId { get; init; }
Property Value
- Guid?
Methods
ForRead(CommandEnvelope, SessionContext)
The owner a received envelope's command is read for.
public static CommandDataOwner ForRead(CommandEnvelope envelope, SessionContext session)
Parameters
envelopeCommandEnvelopeThe envelope whose command is about to be deserialized.
sessionSessionContextThe session the envelope carries.
Returns
- CommandDataOwner
The owner the envelope carries, or the session's data-owner tenant and acting user.
Exceptions
- ArgumentNullException
envelopeorsessionis null.
ForRead(Guid?, Guid?, SessionContext)
The owner a received command is read for, from the owner its carrier holds.
public static CommandDataOwner ForRead(Guid? dataOwnerTenantId, Guid? dataOwnerUserId, SessionContext session)
Parameters
dataOwnerTenantIdGuid?The tenant the carrier names, or null when it names no owner.
dataOwnerUserIdGuid?The user the carrier names beside the tenant, or null.
sessionSessionContextThe session the carrier holds.
Returns
- CommandDataOwner
The carried owner, or the session's data-owner tenant and acting user.
Exceptions
- ArgumentNullException
sessionis null.
ForRecord(object, SessionContext)
The owner the recorded copy of command is written for and attributed to.
public static CommandDataOwner ForRecord(object command, SessionContext session)
Parameters
commandobjectThe command about to be recorded.
sessionSessionContextThe session the command is dispatched under.
Returns
- CommandDataOwner
The named owner, or the session's data-owner tenant and data-owner user.
Exceptions
- ArgumentNullException
commandorsessionis null.- ArgumentException
commandimplements INamesDataOwner and names an empty tenant or an empty user.
ForTransit(object, SessionContext)
The owner the copy of command that travels to a handler is written for.
public static CommandDataOwner ForTransit(object command, SessionContext session)
Parameters
commandobjectThe command about to be serialized.
sessionSessionContextThe session the command is dispatched under.
Returns
- CommandDataOwner
The named owner, or the session's data-owner tenant and acting user.
Exceptions
- ArgumentNullException
commandorsessionis null.- ArgumentException
commandimplements INamesDataOwner and names an empty tenant or an empty user.