Table of Contents

Class DatasetMetadataSerializer

Namespace
EncDotNet.S100.Core.Metadata
Assembly
EncDotNet.S100.Core.dll

Binary (de)serializer for DatasetMetadata, used by the cross-session metadata sidecar cache (issue #467 WS3) so a dataset's cheap "peek" facts — declared spec, extent, CRS, display-scale window, and temporal coverage — survive a process restart and need not be re-parsed from the dataset on a later session.

public static class DatasetMetadataSerializer
Inheritance
DatasetMetadataSerializer
Inherited Members

Remarks

The frame is a small fixed schema: [FormatVersion:int] then the spec name (length-prefixed UTF-8) and edition (three ints), followed by presence-flagged optionals for the extent (four doubles), horizontal CRS EPSG (int), display-scale window (two nullable ints), and temporal coverage (two UTC tick counts). Every optional is guarded by a leading bool so a null field costs one byte and never ambiguously aliases a real value.

Mirroring DrawingInstructionSerializer, deserialization is total: a truncated, corrupt, or version-mismatched frame yields null rather than throwing, so a stale or damaged sidecar degrades to a cache miss. Increment FormatVersion whenever this schema changes so old sidecars are rejected.

Fields

FormatVersion

Schema version stamped into every frame. Bump on any change to the serialized layout so previously persisted sidecars are treated as a miss instead of being misread. Also bumped when the values a reader derives change meaning: version 2 retires sidecars whose DisplayScale was resolved without normalising inverted S-101 DataCoverage scale pairs (FromDeclared(int?, int?)).

public const int FormatVersion = 2

Field Value

int

Methods

Serialize(DatasetMetadata)

Serializes metadata into the binary frame.

public static byte[] Serialize(DatasetMetadata metadata)

Parameters

metadata DatasetMetadata

The metadata to persist.

Returns

byte[]

The serialized bytes.

Exceptions

ArgumentNullException

metadata is null.

TryDeserialize(byte[])

Deserializes metadata previously produced by Serialize(DatasetMetadata). Returns null when the bytes are truncated, corrupt, or carry a mismatched FormatVersion — the caller treats that as a cache miss.

public static DatasetMetadata? TryDeserialize(byte[] bytes)

Parameters

bytes byte[]

The serialized bytes.

Returns

DatasetMetadata

The deserialized metadata, or null on any failure.

Exceptions

ArgumentNullException

bytes is null.