Table of Contents

NotableDateDocumentBuilder Class

Definition

Namespace
Bodu.Globalization.Calendar.Builder
Assembly
Bodu.Globalization.Calendar.Builder.dll
Package
Bodu.Globalization.Calendar.Builder 1.3.0
Source
NotableDateDocumentBuilder.Binary.cs

Provides a fluent, chainable API for authoring a Bodu notable-date document on the notable-date schema, with full-fidelity XML serialization, a JSON-subset surface, and materialization into a NotableDateResource through the canonical loader.

public sealed class NotableDateDocumentBuilder
Inheritance
NotableDateDocumentBuilder
Inherited Members
Extension Methods

Examples

NotableDateResource resource = NotableDateDocumentBuilder.Create("contoso-holidays")
    .AddAdjustmentPolicy("weekend-roll", p => p
        .When(AdjustmentTrigger.IfWeekend)
        .Then(AdjustmentAction.MoveToNextWorkingDay)
        .Emit(EmissionMode.ObservedOnly))
    .AddNotableDate("christmas", "Christmas Day", NotableDateCategory.PublicHoliday, c => c
        .AsNonWorkingByDefault()
        .AddRule("fixed", r => r
            .Fixed(12, 25)
            .WithAdjustment("weekend-roll")))
    .Build();

NotableDateService service = new(resource);

// The same model serializes to XML or JSON for storage or distribution.
NotableDateDocumentBuilder builder = NotableDateDocumentBuilder.Create("contoso-holidays")
    .AddNotableDate("new-year", "New Year's Day", NotableDateCategory.PublicHoliday, c => c
        .AddRule("fixed", r => r.Fixed(1, 1)));
string xml = builder.ToXml();
string json = builder.ToJson();

Remarks

The builder accumulates an in-memory model of the document. Calling ToXml() or Build() renders the model to XML in the urn:bodu:globalization:calendar namespace; building then loads that XML through NotableDateResourceLoader, which remains the single source of validation and assembly. The XML form expresses every feature of the schema, whereas the JSON form rendered by ToJson() is restricted to a subset of the JSON form the loader reads.

Workflow. Obtain a builder with Create() or Create(string, string), declare reusable adjustment policies with AddAdjustmentPolicy(string, Action<AdjustmentPolicyBuilder>), add each notable-date concept with AddNotableDate(string, string, NotableDateCategory, Action<NotableDateDefinitionBuilder>), then terminate by materializing a NotableDateResource with Build(), serializing with ToXml() / ToJson() / Save(string), or wrapping the result with ToProvider().

Methods

AddAdjustmentPolicy(string, Action<AdjustmentPolicyBuilder>)

Adds a reusable adjustment policy and configures it through the supplied delegate.

public NotableDateDocumentBuilder AddAdjustmentPolicy(string id, Action<AdjustmentPolicyBuilder> configure)

Parameters

id string

The stable identifier of the policy.

configure Action<AdjustmentPolicyBuilder>

A delegate that configures the policy.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentException

id is null, empty, or white-space.

ArgumentNullException

configure is null.

AddImport(string, Action<ImportBuilder>?)

Adds an import of an external resource and optionally configures its Use directives.

public NotableDateDocumentBuilder AddImport(string resource, Action<ImportBuilder>? configure = null)

Parameters

resource string

The name of the imported resource.

configure Action<ImportBuilder>

A delegate that configures the import, or null.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentException

resource is null, empty, or white-space.

AddNotableDate(string, string, NotableDateCategory, Action<NotableDateDefinitionBuilder>)

Adds a notable-date concept and configures it through the supplied delegate.

public NotableDateDocumentBuilder AddNotableDate(string id, string displayName, NotableDateCategory category, Action<NotableDateDefinitionBuilder> configure)

Parameters

id string

The stable identifier of the concept.

displayName string

The human-readable display name of the concept.

category NotableDateCategory

The category of the concept.

configure Action<NotableDateDefinitionBuilder>

A delegate that configures the concept.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentException

id or displayName is null, empty, or white-space.

ArgumentNullException

configure is null.

AddOverride(Action<OverrideBuilder>)

Adds override operations through the supplied delegate, appending to any previously configured overrides.

public NotableDateDocumentBuilder AddOverride(Action<OverrideBuilder> configure)

Parameters

configure Action<OverrideBuilder>

A delegate that configures the override operations.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentNullException

configure is null.

Build()

Materializes the document into a validated NotableDateResource through the canonical loader.

public NotableDateResource Build()

Returns

NotableDateResource

The loaded and validated NotableDateResource.

Exceptions

InvalidOperationException

The document is incomplete: the resource identifier is missing, a concept has no rules, a rule has no strategy, or an adjustment policy is missing a trigger, action, or emission.

NotableDateValidationException

The loader produced one or more error diagnostics.

Build(Func<string, string?>?)

Materializes the document into a validated NotableDateResource, resolving imports through the supplied resolver.

public NotableDateResource Build(Func<string, string?>? importResolver)

Parameters

importResolver Func<string, string>

A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.

Returns

NotableDateResource

The loaded and validated NotableDateResource.

Exceptions

InvalidOperationException

The document is incomplete: the resource identifier is missing, a concept has no rules, a rule has no strategy, or an adjustment policy is missing a trigger, action, or emission.

NotableDateValidationException

The loader produced one or more error diagnostics.

Clone()

Creates a deep copy of this document builder.

public NotableDateDocumentBuilder Clone()

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder carrying an independent copy of the document model.

Create()

Creates an empty document builder with no resource identifier configured.

public static NotableDateDocumentBuilder Create()

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder.

Create(string, string)

Creates a document builder with the supplied resource identifier and schema version.

public static NotableDateDocumentBuilder Create(string resourceId, string schemaVersion = "1.0")

Parameters

resourceId string

The resource identifier of the document.

schemaVersion string

The schema version emitted on the root element.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder.

Exceptions

ArgumentException

resourceId or schemaVersion is null, empty, or white-space.

FromJson(string)

Parses a JSON string into a builder.

public static NotableDateDocumentBuilder FromJson(string json)

Parameters

json string

The notable-date document JSON content.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder populated from the JSON.

Examples

// Round-trip a document through its JSON-subset form, then materialize a resource.
NotableDateDocumentBuilder original = NotableDateDocumentBuilder.Create("contoso-holidays")
    .AddNotableDate("new-year", "New Year's Day", NotableDateCategory.PublicHoliday, c => c
        .AddRule("fixed", r => r.Fixed(1, 1)));
string json = original.ToJson();

NotableDateDocumentBuilder reparsed = NotableDateDocumentBuilder.FromJson(json);
NotableDateResource resource = reparsed.Build();

Remarks

Enumeration values and the working week are read with the loader's rules, so they never parse into data the loader would read differently: an enumeration value must name a member (ignoring case; a number is not a name), and workingDays must be the seven-character, Sunday-first binary pattern. Any other value throws a FormatException carrying the message of the loader's BODU-CAL-ENUM or BODU-CAL-WORKING-DAYS diagnostic.

Integers, Booleans and an adjustment trigger's month are read with the loader's rules too: a present value must be a 32-bit integer, an XML-schema Boolean literal (true, false, 1 or 0), or a month name or number, and any other value throws a FormatException carrying the message of the loader's BODU-CAL-VALUE diagnostic.

The attribute values of a strategy, a recurrence and an end strategy are read the same way, each as the loader reads it: an integer, a Boolean, a weekday, week ordinal, direction or invalid-day behavior, a yyyy-MM-dd date, and a month, a fixed strategy's in the calendar the rule's applicability names. A value the loader rejects throws a FormatException carrying the message of its BODU-CAL-VALUE, BODU-CAL-ENUM or BODU-CAL-MONTH diagnostic, and a value it reads is written in the form the schema accepts: a name in another case as the member's name, a number in quotes by its digits, and a month as its English name, or a fixed month in a calendar other than the Gregorian as its number or its month alias.

Text is read as the loader reads it: a string verbatim, a number by its invariant digits, and a Boolean as true or false, so "displayName": 5 reads as the text 5. An item of a list of identifiers, territory codes or tags must be a string, and any other item throws a FormatException carrying the message of the loader's BODU-CAL-VALUE diagnostic; an item of a list of enumeration names is read by its JSON text, so a number there throws as a value that names no member, while an object or an array in a list of names or integers throws as a value of the wrong kind. The metadata, an adjustment policy's description and a rule's comment, which the loader does not read, accept the same scalars. Any other property that holds a value, holding an object or an array, a property that holds an object or a list, such as applicability or tags, holding a value of another kind, and an item of a list of concepts, rules, adjustment policies, imports, uses or overrides that is not an object, throw a FormatException carrying the message of the loader's BODU-CAL-VALUE diagnostic, while the JSON literal null reads as absent, as the loader reads it. The message names a value or an item of the wrong kind by its JSON kind (object, array, number, Boolean or null), as the loader's does, rather than quoting it.

Every field the loader's LoadJson reads is read, including those outside the JSON subset that ToJson() writes (imports, the trigger and action refinements, handler parameters, scope rule references and year bounds, and a PatchRule override's applicability, strategy, recurrence, duration, tags and adjustments), so the builder and the loader read the same document into the same resource. Property names are matched ignoring case, as the loader matches them, so "Strategy" reads as "strategy", and each strategy and recurrence attribute is written under its schema name, while a property the loader does not read is ignored, as the loader ignores it. The few fields the builder's model cannot hold throw a NotSupportedException rather than being dropped. A rule's strategy and recurrence, and a PatchRule override's when it carries either, must name exactly one recognized kind between them, matched ignoring case as the loader matches it, and an untilDate must declare an end strategy that names exactly one, or the document throws a FormatException carrying the message of the loader's BODU-CAL-RULE-SOURCE, BODU-CAL-DURATION-NOEND or BODU-CAL-DURATION-CONFLICT diagnostic, rather than building the first kind alone or none. An override's operation is matched ignoring case, as the loader matches it; one that is absent or names no operation throws a FormatException carrying the message of the loader's BODU-CAL-ENUM diagnostic, rather than being read as a PatchRule, and an AddRule override without a rule throws one carrying the message of its BODU-CAL-SCHEMA diagnostic, rather than adding a rule with an empty identifier.

The values the XML schema requires and the ranges it holds integers to are held to as the loader holds a JSON document to them: an object that lacks a property the schema requires of it (the root's schemaVersion and resourceId, a concept's id, displayName and category, a strategy's month, …), a concept's rules or a weekly recurrence's days that holds no item, and an integer outside the schema's range (a day count or interval below 1, a year outside 0 to 65535, a day of the month outside 1 to 31, an ISO week outside 1 to 53, or an ordinal that is zero, outside -366 to 366, or written with a plus sign or a leading zero) throw a FormatException carrying the message of the loader's BODU-CAL-SCHEMA diagnostic, rather than being read with a default in the value's place or written for the schema to reject at Build(). An empty list that is optional reads as absent. Each identifier, reference and territory code is held to the pattern the schema requires of it, as the loader holds it: the resource identifier, the concept, rule and adjustment policy identifiers, the references of an action, a strategy, an override, an import use and a scope, the adjustment policy references of a rule, a patch and an import use, an import use's alias, and the territory codes of a scope, an applicability and an import use. A value that breaks its pattern, such as New-Year for a concept identifier, throws a FormatException carrying the message of the loader's BODU-CAL-SCHEMA diagnostic.

Parsing does not otherwise validate the document: a document the loader would reject for a reason other than a malformed value, such as a dangling reference, can still parse. Validate with Validate() or TryBuild(out NotableDateResource?, out IReadOnlyList<NotableDateValidationDiagnostic>), or load the text with NotableDateResourceLoader, when the input is not trusted.

Exceptions

ArgumentException

json is null, empty, or white-space.

FormatException

json is not well-formed or is not a notable-date document, an enumeration, integer, Boolean, date, month, trigger-month or workingDays value does not parse, a property that holds a value holds an object or an array, a property that holds an object or a list holds a value of another kind, an item of a list of identifiers, territory codes or tags is not a string, an item of a list of concepts, rules, adjustment policies, imports, uses or overrides is not an object, a rule's strategy and recurrence, or a PatchRule override's when it carries either, name no recognized kind or more than one between them, an untilDate declares no end strategy or one that names no recognized kind or more than one, an override's operation is absent or names no operation, an object lacks a property the XML schema requires of it, a concept's rules or a weekly recurrence's days holds no item, an integer lies outside the range the XML schema allows, or an identifier, reference or territory code does not match the pattern the XML schema requires of it.

NotSupportedException

json declares a field the builder's document model cannot hold: an empty tags or adjustments list on a PatchRule override, an empty adjustments list on an import use, a scope rule reference that is a bare rule identifier, a handler parameter whose value is an object or an array, or a metadata name, description or source, an adjustment policy's description or a rule's comment that is an object or an array.

FromJsonObject(JsonObject)

Parses a JsonObject into a builder.

public static NotableDateDocumentBuilder FromJsonObject(JsonObject json)

Parameters

json JsonObject

The notable-date document JSON object.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder populated from the object.

Remarks

Values are read as FromJson(string) reads them; see its remarks.

Exceptions

ArgumentNullException

json is null.

FormatException

An enumeration, integer, Boolean, date, month, trigger-month or workingDays value does not parse, a property that holds a value holds an object or an array, a property that holds an object or a list holds a value of another kind, an item of a list of identifiers, territory codes or tags is not a string, an item of a list of concepts, rules, adjustment policies, imports, uses or overrides is not an object, a rule's strategy and recurrence, or a PatchRule override's when it carries either, name no recognized kind or more than one between them, an untilDate declares no end strategy or one that names no recognized kind or more than one, an override's operation is absent or names no operation, an object lacks a property the XML schema requires of it, a concept's rules or a weekly recurrence's days holds no item, an integer lies outside the range the XML schema allows, or an identifier, reference or territory code does not match the pattern the XML schema requires of it.

NotSupportedException

json declares a field the builder's document model cannot hold; see FromJson(string).

FromXDocument(XDocument)

Parses an XDocument into a builder.

public static NotableDateDocumentBuilder FromXDocument(XDocument document)

Parameters

document XDocument

The notable-date document.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder populated from the document.

Remarks

Values are read as FromXml(string) reads them; see its remarks.

Exceptions

ArgumentNullException

document is null.

FormatException

The root element is not a notable-date resource element, or an enumeration, integer, Boolean, trigger-month or workingDays value does not parse.

FromXml(string)

Parses an XML document into a builder.

public static NotableDateDocumentBuilder FromXml(string xml)

Parameters

xml string

The notable-date document XML content.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder populated from the XML.

Examples

// Round-trip a document through its XML form: serialize, then re-parse into an equivalent builder.
NotableDateDocumentBuilder original = NotableDateDocumentBuilder.Create("contoso-holidays")
    .AddNotableDate("new-year", "New Year's Day", NotableDateCategory.PublicHoliday, c => c
        .AddRule("fixed", r => r.Fixed(1, 1)));
string xml = original.ToXml();

NotableDateDocumentBuilder reparsed = NotableDateDocumentBuilder.FromXml(xml);
NotableDateResource resource = reparsed.Build();

Remarks

Enumeration values and the working week are read with the loader's rules, so they never parse into data the loader would read differently: an enumeration value must name a member (ignoring case; a number is not a name), and workingDays must be the seven-character, Sunday-first binary pattern. Any other value throws a FormatException carrying the message of the loader's BODU-CAL-ENUM or BODU-CAL-WORKING-DAYS diagnostic.

Integers, Booleans and an adjustment trigger's month are read with the loader's rules too: a present value must be a 32-bit integer, an XML-schema Boolean literal (true, false, 1 or 0), or a month name or number, and any other value throws a FormatException carrying the message of the loader's BODU-CAL-VALUE diagnostic.

Parsing does not otherwise validate the document: a document the loader would reject for a reason other than a malformed value, such as a dangling reference, can still parse. Validate with Validate() or TryBuild(out NotableDateResource?, out IReadOnlyList<NotableDateValidationDiagnostic>), or load the text with NotableDateResourceLoader, when the input is not trusted.

Exceptions

ArgumentException

xml is null, empty, or white-space.

FormatException

xml is not well-formed or is not a notable-date document, or an enumeration, integer, Boolean, trigger-month or workingDays value does not parse.

Load(string)

Reads a document from a file and parses it into a builder, inferring the format from the file extension.

public static NotableDateDocumentBuilder Load(string path)

Parameters

path string

The source file path. A .xml extension reads XML; a .json extension reads JSON.

Returns

NotableDateDocumentBuilder

A new NotableDateDocumentBuilder populated from the file.

Remarks

Like FromXml(string) and FromJson(string), loading reads each value with the loader's rules but does not otherwise validate the document; see their remarks.

Exceptions

ArgumentException

path is null, empty, white-space, or has an extension other than .xml, .json, or .bcal.

NotSupportedException

path has a .bcal extension: a binary rule pack is compiled output that cannot be reopened for editing (load it with LoadBinary(Stream)); or a .json file declares a field the builder's document model cannot hold; see FromJson(string).

FormatException

The file content is not a well-formed notable-date document, or holds a value or a field that FromXml(string), for an .xml file, or FromJson(string), for a .json file, rejects with a FormatException; see their exceptions.

Save(string)

Serializes the document to a file, inferring the format from the file extension.

public void Save(string path)

Parameters

path string

The destination file path. A .xml extension writes XML, a .json extension writes JSON, and a .bcal extension writes a binary rule pack.

Examples

NotableDateDocumentBuilder builder = NotableDateDocumentBuilder.Create("contoso-holidays")
    .AddNotableDate("new-year", "New Year's Day", NotableDateCategory.PublicHoliday, c => c
        .AddRule("fixed", r => r.Fixed(1, 1)));

// The extension selects the format: .xml writes XML, .json writes JSON.
builder.Save("contoso-holidays.xml");
builder.Save("contoso-holidays.json");

// Reload the document later and build a service over it.
NotableDateResource resource = NotableDateDocumentBuilder.Load("contoso-holidays.xml").Build();

Remarks

XML and JSON are written as UTF-8 without a byte order mark, and the XML declaration names that encoding.

Exceptions

ArgumentException

path is null, empty, white-space, or has an extension other than .xml, .json, or .bcal.

InvalidOperationException

The document is incomplete.

NotSupportedException

A JSON target is requested but the document uses a feature the JSON subset cannot represent.

NotableDateValidationException

A .bcal target is requested and the document produced one or more error diagnostics.

Save(string, NotableDateDocumentFormat)

Serializes the document to a file in the specified format.

public void Save(string path, NotableDateDocumentFormat format)

Parameters

path string

The destination file path.

format NotableDateDocumentFormat

The serialization format.

Remarks

XML and JSON are written as UTF-8 without a byte order mark, and the XML declaration names that encoding.

Exceptions

ArgumentException

path is null, empty, or white-space.

InvalidOperationException

The document is incomplete.

NotSupportedException

A JSON target is requested but the document uses a feature the JSON subset cannot represent.

NotableDateValidationException

A binary target is requested and the document produced one or more error diagnostics.

SaveBinary(Stream, Func<string, string?>?)

Compiles the document to a sealed binary rule pack written to a stream.

public void SaveBinary(Stream stream, Func<string, string?>? importResolver = null)

Parameters

stream Stream

The writable stream receiving the pack.

importResolver Func<string, string>

A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.

Exceptions

ArgumentNullException

stream is null.

InvalidOperationException

The document is incomplete.

NotableDateValidationException

The document produced one or more error diagnostics.

SaveBinary(string)

Compiles the document to a sealed binary rule pack on disk.

public void SaveBinary(string path)

Parameters

path string

The destination file path, conventionally with the .bcal extension.

Remarks

The document is materialized through Build() first, so only content that passed the canonical loader's validation is ever encoded; the pack then loads via LoadBinary(Stream) without re-parsing or re-validating.

Exceptions

ArgumentException

path is null, empty, or white-space.

InvalidOperationException

The document is incomplete.

NotableDateValidationException

The document produced one or more error diagnostics.

SaveBinary(string, Func<string, string?>?)

Compiles the document to a sealed binary rule pack on disk, resolving imports through the supplied resolver.

public void SaveBinary(string path, Func<string, string?>? importResolver)

Parameters

path string

The destination file path, conventionally with the .bcal extension.

importResolver Func<string, string>

A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.

Exceptions

ArgumentException

path is null, empty, or white-space.

InvalidOperationException

The document is incomplete.

NotableDateValidationException

The document produced one or more error diagnostics.

ToJson()

Serializes the document to an indented JSON string in the JSON-subset form.

public string ToJson()

Returns

string

The serialized JSON.

Exceptions

InvalidOperationException

The document is incomplete.

NotSupportedException

The document uses a feature the JSON subset cannot represent.

ToJsonObject()

Serializes the document to a JsonObject in the JSON-subset form.

public JsonObject ToJsonObject()

Returns

JsonObject

The serialized JSON object.

Exceptions

InvalidOperationException

The document is incomplete.

NotSupportedException

The document uses a feature the JSON subset cannot represent.

ToProvider()

Materializes the document and wraps it in a mutable provider.

public INotableDateResourceProvider ToProvider()

Returns

INotableDateResourceProvider

An INotableDateResourceProvider exposing the built resource.

Exceptions

InvalidOperationException

The document is incomplete.

NotableDateValidationException

The loader produced one or more error diagnostics.

ToXDocument()

Serializes the document to an XDocument in the urn:bodu:globalization:calendar namespace.

public XDocument ToXDocument()

Returns

XDocument

The serialized document.

Exceptions

InvalidOperationException

The document is incomplete.

ToXml()

Serializes the document to an indented XML string in the urn:bodu:globalization:calendar namespace.

public string ToXml()

Returns

string

The serialized XML.

Remarks

The XML declaration names the UTF-8 encoding, so the text can be written to a file as UTF-8, as Save(string) writes it, and read back by any XML reader.

Exceptions

InvalidOperationException

The document is incomplete.

TryBuild(out NotableDateResource?, out IReadOnlyList<NotableDateValidationDiagnostic>)

Attempts to materialize the document into a validated NotableDateResource, collecting every diagnostic instead of throwing on an invalid document.

public bool TryBuild(out NotableDateResource? resource, out IReadOnlyList<NotableDateValidationDiagnostic> diagnostics)

Parameters

resource NotableDateResource

The built resource, or null when the document does not validate.

diagnostics IReadOnlyList<NotableDateValidationDiagnostic>

Every diagnostic serialization and validation produced.

Returns

bool

true when the document built without error-severity diagnostics; otherwise false.

TryBuild(Func<string, string?>?, out NotableDateResource?, out IReadOnlyList<NotableDateValidationDiagnostic>)

Attempts to materialize the document into a validated NotableDateResource resolving imports through the supplied resolver, collecting every diagnostic instead of throwing on an invalid document.

public bool TryBuild(Func<string, string?>? importResolver, out NotableDateResource? resource, out IReadOnlyList<NotableDateValidationDiagnostic> diagnostics)

Parameters

importResolver Func<string, string>

A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.

resource NotableDateResource

The built resource, or null when the document does not validate.

diagnostics IReadOnlyList<NotableDateValidationDiagnostic>

Every diagnostic serialization and validation produced.

Returns

bool

true when the document built without error-severity diagnostics; otherwise false.

Validate()

Lints the document, returning every diagnostic the canonical loader's validation would produce - errors, warnings, and informational messages - without throwing.

public IReadOnlyList<NotableDateValidationDiagnostic> Validate()

Returns

IReadOnlyList<NotableDateValidationDiagnostic>

The collected diagnostics; empty when the document is valid.

Remarks

Validation runs the same pipeline as Build() - the document is serialized to XML and passed through NotableDateResourceLoader - so a clean result guarantees Build() succeeds for the same document. A document too incomplete to serialize (a missing resource identifier, a concept with no rules, a rule with no strategy) is reported as a BODU-CAL-BUILDER-INCOMPLETE error diagnostic rather than an exception.

Validate(Func<string, string?>?)

Lints the document against the supplied import resolver, returning every diagnostic without throwing.

public IReadOnlyList<NotableDateValidationDiagnostic> Validate(Func<string, string?>? importResolver)

Parameters

importResolver Func<string, string>

A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.

Returns

IReadOnlyList<NotableDateValidationDiagnostic>

The collected diagnostics; empty when the document is valid.

WithMetadata(string?, string?, params string[])

Sets the document metadata name, description, and sources.

public NotableDateDocumentBuilder WithMetadata(string? name = null, string? description = null, params string[] sources)

Parameters

name string

The metadata name, or null to leave it unset.

description string

The metadata description, or null to leave it unset.

sources string[]

The metadata source entries.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentNullException

sources is null.

WithResolutionPolicy(Action<ResolutionPolicyBuilder>)

Configures the document-level resolution policy through the supplied delegate.

public NotableDateDocumentBuilder WithResolutionPolicy(Action<ResolutionPolicyBuilder> configure)

Parameters

configure Action<ResolutionPolicyBuilder>

A delegate that configures the resolution policy.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentNullException

configure is null.

WithResourceId(string)

Sets the resource identifier of the document.

public NotableDateDocumentBuilder WithResourceId(string resourceId)

Parameters

resourceId string

The resource identifier.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentException

resourceId is null, empty, or white-space.

WithSchemaVersion(string)

Sets the schema version emitted on the root element.

public NotableDateDocumentBuilder WithSchemaVersion(string schemaVersion)

Parameters

schemaVersion string

The schema version.

Returns

NotableDateDocumentBuilder

The same NotableDateDocumentBuilder instance, enabling chained calls.

Exceptions

ArgumentException

schemaVersion is null, empty, or white-space.

Applies to

ProductVersions
.NET8, 10

See Also