Table of Contents

Class MachiningStep.CollidedKeyPair

Namespace
Hi.MachiningSteps
Assembly
HiMech.dll

A pair of collided keys that indicates two entities are in collision. A step's pairs are persisted together as one record (WriteBin(BinaryWriter, CollidedKeyPair[]), ReadBin(BinaryReader)).

public record MachiningStep.CollidedKeyPair : IEquatable<MachiningStep.CollidedKeyPair>
Inheritance
MachiningStep.CollidedKeyPair
Implements
Inherited Members
Extension Methods

Constructors

CollidedKeyPair(string, string)

A pair of collided keys that indicates two entities are in collision. A step's pairs are persisted together as one record (WriteBin(BinaryWriter, CollidedKeyPair[]), ReadBin(BinaryReader)).

public CollidedKeyPair(string KeyA, string KeyB)

Parameters

KeyA string
KeyB string

Properties

KeyA

public string KeyA { get; init; }

Property Value

string

KeyB

public string KeyB { get; init; }

Property Value

string

Methods

ReadBin(BinaryReader)

Reads the record WriteBin(BinaryWriter, CollidedKeyPair[]) wrote: null for the null record, an empty array for a count of 0, else every pair with its two keys (a null key stays null). The version byte is judged before a byte of the payload is read, the count as soon as it is read.

public static MachiningStep.CollidedKeyPair[] ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

The reader positioned at the record's first byte.

Returns

CollidedKeyPair[]

The pairs read, or null for the null record.

Exceptions

InvalidDataException

The record's version is not this build's, or its count is below -1.

EndOfStreamException

The stream ends inside the record.

WriteBin(BinaryWriter, CollidedKeyPair[])

Writes a step's collided pairs as one record: the version byte, the count (int32: -1 for a null array, which the record tells from an empty one; 0 for no pair), then every pair as a presence byte and the string of KeyA, a presence byte and the string of KeyB – a null key writes its presence byte 0 and no string, a string is Write(string)'s length-prefixed UTF-8. The array is checked before the first byte is written, so an array that cannot be recorded leaves the stream as it was.

public static void WriteBin(BinaryWriter writer, MachiningStep.CollidedKeyPair[] pairs)

Parameters

writer BinaryWriter

The writer to write to.

pairs CollidedKeyPair[]

The pairs to write; null writes the null record.

Exceptions

ArgumentException

An element of pairs is null.