Skip to main content
Table of Contents

Struct CommandDataOwner

Namespace
Stratara.Shared.Security
Assembly
Stratara.Shared.dll

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

TenantId Guid

The tenant the fields are encrypted for.

UserId Guid?

The user the fields are encrypted for, or null.

Named bool

true 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

true when the command named this owner; false when it was taken from the session.

public bool Named { get; init; }

Property Value

bool

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

Guid

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

envelope CommandEnvelope

The envelope whose command is about to be deserialized.

session SessionContext

The session the envelope carries.

Returns

CommandDataOwner

The owner the envelope carries, or the session's data-owner tenant and acting user.

Exceptions

ArgumentNullException

envelope or session is 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

dataOwnerTenantId Guid?

The tenant the carrier names, or null when it names no owner.

dataOwnerUserId Guid?

The user the carrier names beside the tenant, or null.

session SessionContext

The session the carrier holds.

Returns

CommandDataOwner

The carried owner, or the session's data-owner tenant and acting user.

Exceptions

ArgumentNullException

session is 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

command object

The command about to be recorded.

session SessionContext

The session the command is dispatched under.

Returns

CommandDataOwner

The named owner, or the session's data-owner tenant and data-owner user.

Exceptions

ArgumentNullException

command or session is null.

ArgumentException

command implements 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

command object

The command about to be serialized.

session SessionContext

The session the command is dispatched under.

Returns

CommandDataOwner

The named owner, or the session's data-owner tenant and acting user.

Exceptions

ArgumentNullException

command or session is null.

ArgumentException

command implements INamesDataOwner and names an empty tenant or an empty user.