NotableDateBinaryResource Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.3.0
Writes and reads the sealed notable-date binary rule-pack format (.bcal): a compact, integrity-checked,
reflection-free encoding of a validated NotableDateResource.
public static class NotableDateBinaryResource
- Inheritance
-
NotableDateBinaryResource
- Inherited Members
Remarks
Write(NotableDateResource, Stream) runs the loader's identifier, range, enumeration, duplicate and cross-reference checks on the resource before it encodes anything, and refuses a resource the loader would reject with the NotableDateValidationException and diagnostics the loader reports, so a resource assembled in code is held to the rules a document is. Reading a pack skips parsing and that validation entirely - the trim- and AOT-friendly load path - so a pack not produced by Write(NotableDateResource, Stream), such as one edited by hand, is not revalidated. The format is sealed: it enumerates the engine's strategy, recurrence, and duration types exhaustively with one-byte discriminators, carries no type names and no extension points, and the reader rejects unknown versions, unknown discriminators, undefined enum values, out-of-range references, values a model constructor refuses, truncation, and payload-digest mismatches with NotableDateBinaryFormatException.
Writing is byte-stable: the same resource always produces the same bytes, so build systems can use pack outputs for up-to-date checks.
A pack is written at format version 1 unless an adjustment scope names a concept's rule (<Rule notableDateRef="…" ruleRef="…" />),
which needs version 2. The two versions share one layout; version 2 exists so that a reader predating
concept-qualified rule references rejects the pack instead of matching the reference against rule identifiers alone.
The reader accepts both, and a version 1 scope's rule identifier keeps matching that rule in every concept.
Methods
Read(Stream)
Reads a resource from a stream in the binary rule-pack format.
public static NotableDateResource Read(Stream stream)
Parameters
streamStreamThe readable stream positioned at the start of a pack.
Returns
- NotableDateResource
The decoded resource.
Remarks
Reading checks the pack's structure, enumeration values, string references and payload digest, and builds each value through its model constructor, but does not run the loader's identifier, range, duplicate or cross-reference checks, which Write(NotableDateResource, Stream) ran before encoding. A pack not produced by Write(NotableDateResource, Stream), such as one edited by hand and given a matching digest, is therefore not revalidated; load the document it was compiled from to validate it.
Exceptions
- ArgumentNullException
streamis null.- NotableDateBinaryFormatException
The stream is not a notable-date binary rule pack, declares an unsupported format version, is truncated or corrupted, or carries a value outside the sealed format's tables or a model constructor's domain.
Write(NotableDateResource, Stream)
Writes a resource to a stream in the binary rule-pack format, accepting only the built-in algorithm keys.
public static void Write(NotableDateResource resource, Stream stream)
Parameters
resourceNotableDateResourceThe resource to encode.
streamStreamThe writable stream receiving the pack.
Remarks
A resource the loader produced passes the checks, unless it was loaded with a custom algorithm registry; write such a resource with Write(NotableDateResource, Stream, INotableDateAlgorithmRegistry?).
Exceptions
- ArgumentNullException
resourceorstreamis null.- NotableDateValidationException
The resource fails one of the loader's identifier, range, enumeration, duplicate or cross-reference checks, such as a concept identifier that is not an identifier, two concepts sharing one, or an algorithm key that is not built in; the Diagnostics are those the loader reports, and nothing is written.
- NotSupportedException
A rule uses a calculation strategy, recurrence strategy, or duration definition outside the sealed set the format enumerates, such as a custom IDateCalculationStrategy in a resource assembled in code; the message names the unsupported type.
Write(NotableDateResource, Stream, INotableDateAlgorithmRegistry?)
Writes a resource to a stream in the binary rule-pack format, accepting the algorithm keys a registry declares as well as the built-in ones.
public static void Write(NotableDateResource resource, Stream stream, INotableDateAlgorithmRegistry? algorithms)
Parameters
resourceNotableDateResourceThe resource to encode.
streamStreamThe writable stream receiving the pack.
algorithmsINotableDateAlgorithmRegistryThe custom algorithm registry whose keys the resource's algorithm strategies may name, as the loader accepts them, or null to accept only the built-in keys.
Remarks
The checks are those the loader runs on the resource it assembles: each identifier, reference and territory code
against the pattern the notable-date schema requires of it, and each number the schema bounds against its range
(BODU-CAL-SCHEMA, or BODU-CAL-VALUE for an adjustment trigger's month), each enumeration value
outside a strategy or recurrence against the members its type defines (BODU-CAL-ENUM), duplicate concept,
rule and adjustment-policy identifiers, adjustment and strategy references that do not resolve, inverted year
bounds, adjustment actions missing their target or handler, and algorithm keys. The registry is not recorded in
the pack; a reader resolves an algorithm key against the registry its service is given.
Exceptions
- ArgumentNullException
resourceorstreamis null.- NotableDateValidationException
The resource fails one of the loader's identifier, range, enumeration, duplicate or cross-reference checks, such as a concept identifier that is not an identifier, two concepts sharing one, or an algorithm key that is neither built in nor declared by
algorithms; the Diagnostics are those the loader reports, and nothing is written.- NotSupportedException
A rule uses a calculation strategy, recurrence strategy, or duration definition outside the sealed set the format enumerates, such as a custom IDateCalculationStrategy in a resource assembled in code; the message names the unsupported type.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |