NotableDateDocumentBuilder Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Builder
- Assembly
- Bodu.Globalization.Calendar.Builder.dll
- Package
- Bodu.Globalization.Calendar.Builder 1.3.0
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
idstringThe stable identifier of the policy.
configureAction<AdjustmentPolicyBuilder>A delegate that configures the policy.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
idis null, empty, or white-space.- ArgumentNullException
configureis 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
resourcestringThe name of the imported resource.
configureAction<ImportBuilder>A delegate that configures the import, or null.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
resourceis 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
idstringThe stable identifier of the concept.
displayNamestringThe human-readable display name of the concept.
categoryNotableDateCategoryThe category of the concept.
configureAction<NotableDateDefinitionBuilder>A delegate that configures the concept.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
idordisplayNameis null, empty, or white-space.- ArgumentNullException
configureis null.
AddOverride(Action<OverrideBuilder>)
Adds override operations through the supplied delegate, appending to any previously configured overrides.
public NotableDateDocumentBuilder AddOverride(Action<OverrideBuilder> configure)
Parameters
configureAction<OverrideBuilder>A delegate that configures the override operations.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentNullException
configureis 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
importResolverFunc<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
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
resourceIdstringThe resource identifier of the document.
schemaVersionstringThe schema version emitted on the root element.
Returns
Exceptions
- ArgumentException
resourceIdorschemaVersionis null, empty, or white-space.
FromJson(string)
Parses a JSON string into a builder.
public static NotableDateDocumentBuilder FromJson(string json)
Parameters
jsonstringThe 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
jsonis null, empty, or white-space.- FormatException
jsonis not well-formed or is not a notable-date document, an enumeration, integer, Boolean, date, month, trigger-month orworkingDaysvalue 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'sstrategyandrecurrence, or aPatchRuleoverride's when it carries either, name no recognized kind or more than one between them, anuntilDatedeclares no end strategy or one that names no recognized kind or more than one, an override'soperationis absent or names no operation, an object lacks a property the XML schema requires of it, a concept'srulesor a weekly recurrence'sdaysholds 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
jsondeclares a field the builder's document model cannot hold: an emptytagsoradjustmentslist on aPatchRuleoverride, an emptyadjustmentslist 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
jsonJsonObjectThe 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
jsonis null.- FormatException
An enumeration, integer, Boolean, date, month, trigger-month or
workingDaysvalue 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'sstrategyandrecurrence, or aPatchRuleoverride's when it carries either, name no recognized kind or more than one between them, anuntilDatedeclares no end strategy or one that names no recognized kind or more than one, an override'soperationis absent or names no operation, an object lacks a property the XML schema requires of it, a concept'srulesor a weekly recurrence'sdaysholds 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
jsondeclares 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
documentXDocumentThe 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
documentis null.- FormatException
The root element is not a notable-date resource element, or an enumeration, integer, Boolean, trigger-month or
workingDaysvalue does not parse.
FromXml(string)
Parses an XML document into a builder.
public static NotableDateDocumentBuilder FromXml(string xml)
Parameters
xmlstringThe 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
xmlis null, empty, or white-space.- FormatException
xmlis not well-formed or is not a notable-date document, or an enumeration, integer, Boolean, trigger-month orworkingDaysvalue 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
pathstringThe source file path. A
.xmlextension reads XML; a.jsonextension 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
pathis null, empty, white-space, or has an extension other than.xml,.json, or.bcal.- NotSupportedException
pathhas a.bcalextension: a binary rule pack is compiled output that cannot be reopened for editing (load it with LoadBinary(Stream)); or a.jsonfile 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
.xmlfile, or FromJson(string), for a.jsonfile, 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
pathstringThe destination file path. A
.xmlextension writes XML, a.jsonextension writes JSON, and a.bcalextension 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
pathis 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
.bcaltarget 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
pathstringThe destination file path.
formatNotableDateDocumentFormatThe 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
pathis 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
streamStreamThe writable stream receiving the pack.
importResolverFunc<string, string>A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.
Exceptions
- ArgumentNullException
streamis 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
pathstringThe destination file path, conventionally with the
.bcalextension.
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
pathis 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
pathstringThe destination file path, conventionally with the
.bcalextension.importResolverFunc<string, string>A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.
Exceptions
- ArgumentException
pathis 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
resourceNotableDateResourceThe built resource, or null when the document does not validate.
diagnosticsIReadOnlyList<NotableDateValidationDiagnostic>Every diagnostic serialization and validation produced.
Returns
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
importResolverFunc<string, string>A delegate mapping a resource name to its XML or JSON content, or null to resolve no imports.
resourceNotableDateResourceThe built resource, or null when the document does not validate.
diagnosticsIReadOnlyList<NotableDateValidationDiagnostic>Every diagnostic serialization and validation produced.
Returns
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
importResolverFunc<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
namestringThe metadata name, or null to leave it unset.
descriptionstringThe metadata description, or null to leave it unset.
sourcesstring[]The metadata source entries.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentNullException
sourcesis null.
WithResolutionPolicy(Action<ResolutionPolicyBuilder>)
Configures the document-level resolution policy through the supplied delegate.
public NotableDateDocumentBuilder WithResolutionPolicy(Action<ResolutionPolicyBuilder> configure)
Parameters
configureAction<ResolutionPolicyBuilder>A delegate that configures the resolution policy.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentNullException
configureis null.
WithResourceId(string)
Sets the resource identifier of the document.
public NotableDateDocumentBuilder WithResourceId(string resourceId)
Parameters
resourceIdstringThe resource identifier.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
resourceIdis null, empty, or white-space.
WithSchemaVersion(string)
Sets the schema version emitted on the root element.
public NotableDateDocumentBuilder WithSchemaVersion(string schemaVersion)
Parameters
schemaVersionstringThe schema version.
Returns
- NotableDateDocumentBuilder
The same NotableDateDocumentBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
schemaVersionis null, empty, or white-space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |