Table of Contents

Struct MixedChange<T1, T2, T3>

Namespace
DynaSharp.Streams
Assembly
DynaSharp.dll

One change of a typed read of several entities: a Change<T> of one of the types, from shop.ReadChangesAsync<Customer, Order>(streams, ...). Ask with change.Is(out Change<Customer>? customer), or handle every case with Match, which is what stays correct when a type is added.

public readonly struct MixedChange<T1, T2, T3> where T1 : IDynamoDbDiscriminated<T1> where T2 : IDynamoDbDiscriminated<T2> where T3 : IDynamoDbDiscriminated<T3>

Type Parameters

T1

The first type.

T2

The second type.

T3

The third type.

Inherited Members

Remarks

It is to Change<T> what Mixed<T1, T2, T3> of a mixed read is to an entity, with the same members. That one is a document, which a read fills and From<T>(T) writes; this one holds a change, which is neither. The default value holds nothing, and Match throws on it; a typed read never gives one. A test builds one with the constructor of its type.

Constructors

MixedChange(Change<T1>)

Initializes a new instance of the MixedChange<T1, T2, T3> struct that holds a change of the first type, as a typed read gives it, so that a test of code that handles the changes of a reading builds its input: new MixedChange<Customer, Order, Invoice>(new Change<Customer> { Kind = OperationType.Insert, After = customer, Record = new ChangeRecord() }).

public MixedChange(Change<T1> change)

Parameters

change Change<T1>

The change.

Remarks

There is one constructor per type, and the type of the argument picks it. Two equal types make the call ambiguous, which does not compile, and a reading of them could not tell them apart either: it throws ArgumentException.

Exceptions

ArgumentNullException

change is null.

MixedChange(Change<T2>)

Initializes a new instance of the MixedChange<T1, T2, T3> struct that holds a change of the second type, as a typed read gives it, so that a test of code that handles the changes of a reading builds its input: new MixedChange<Customer, Order, Invoice>(new Change<Order> { Kind = OperationType.Insert, After = order, Record = new ChangeRecord() }).

public MixedChange(Change<T2> change)

Parameters

change Change<T2>

The change.

Remarks

There is one constructor per type, and the type of the argument picks it. Two equal types make the call ambiguous, which does not compile, and a reading of them could not tell them apart either: it throws ArgumentException.

Exceptions

ArgumentNullException

change is null.

MixedChange(Change<T3>)

Initializes a new instance of the MixedChange<T1, T2, T3> struct that holds a change of the third type, as a typed read gives it, so that a test of code that handles the changes of a reading builds its input: new MixedChange<Customer, Order, Invoice>(new Change<Invoice> { Kind = OperationType.Insert, After = invoice, Record = new ChangeRecord() }).

public MixedChange(Change<T3> change)

Parameters

change Change<T3>

The change.

Remarks

There is one constructor per type, and the type of the argument picks it. Two equal types make the call ambiguous, which does not compile, and a reading of them could not tell them apart either: it throws ArgumentException.

Exceptions

ArgumentNullException

change is null.

Methods

Is(out Change<T1>?)

Gets the change if it is of the first type.

public bool Is(out Change<T1>? change)

Parameters

change Change<T1>

The change, or null.

Returns

bool

true if the change is of this type.

Is(out Change<T2>?)

Gets the change if it is of the second type.

public bool Is(out Change<T2>? change)

Parameters

change Change<T2>

The change, or null.

Returns

bool

true if the change is of this type.

Is(out Change<T3>?)

Gets the change if it is of the third type.

public bool Is(out Change<T3>? change)

Parameters

change Change<T3>

The change, or null.

Returns

bool

true if the change is of this type.

Match(Action<Change<T1>>, Action<Change<T2>>, Action<Change<T3>>)

Does something with the change, with one action per type, so no type can be forgotten.

public void Match(Action<Change<T1>> first, Action<Change<T2>> second, Action<Change<T3>> third)

Parameters

first Action<Change<T1>>

What to do with a change of the first type.

second Action<Change<T2>>

What to do with a change of the second type.

third Action<Change<T3>>

What to do with a change of the third type.

Exceptions

ArgumentNullException

An action is null.

InvalidOperationException

This is the default value, which holds nothing.

Match<TResult>(Func<Change<T1>, TResult>, Func<Change<T2>, TResult>, Func<Change<T3>, TResult>)

Computes a result from the change, with one function per type, so no type can be forgotten.

public TResult Match<TResult>(Func<Change<T1>, TResult> first, Func<Change<T2>, TResult> second, Func<Change<T3>, TResult> third)

Parameters

first Func<Change<T1>, TResult>

What to do with a change of the first type.

second Func<Change<T2>, TResult>

What to do with a change of the second type.

third Func<Change<T3>, TResult>

What to do with a change of the third type.

Returns

TResult

The result of the function of the type of the change.

Type Parameters

TResult

The type of the result.

Exceptions

ArgumentNullException

A function is null.

InvalidOperationException

This is the default value, which holds nothing.