Table of Contents

Class ConventionsXml

Namespace
NanoQL.Extensions.Conventions
Assembly
NanoQL.Extensions.dll

Reads and writes conventions documents: one Conventions element in the namespace Namespace, validated by its XML Schema on every read.

public static class ConventionsXml
Inheritance
ConventionsXml
Inherited Members

Remarks

A document's root may be the Conventions element or any element holding one. A schema violation is the System.Xml.Schema.XmlSchemaValidationException .NET raises, with its line and position. DTDs are refused and nothing outside the document is resolved.

The writer writes the canonical form: the records in order, attributes name and base first, two-space indents, LF line ends, UTF-8 without a byte-order mark and a final newline; each record's and the root's foreign attributes and elements are written back where they were read.

Fields

Namespace

The conventions' namespace.

public const string Namespace = "https://nanoql.org/schemas/conventions"

Field Value

string

Methods

Read(IEnumerable<string>)

Reads several conventions files into one snapshot, in order, refusing a name two of them define.

public static ConventionSnapshot Read(IEnumerable<string> paths)

Parameters

paths IEnumerable<string>

The files' paths.

Returns

ConventionSnapshot

Their records.

Exceptions

ArgumentNullException

paths or a path is null.

ArgumentException

Two files define one name in one value kind.

XmlSchemaValidationException

A document breaks the schema.

Read(Stream, string?)

Reads a conventions document from a stream.

public static ConventionSnapshot Read(Stream stream, string? source = null)

Parameters

stream Stream

The stream.

source string

The source each record reports, or null.

Returns

ConventionSnapshot

Its records.

Exceptions

ArgumentNullException

stream is null.

XmlSchemaValidationException

The document breaks the schema.

Read(TextReader, string?)

Reads a conventions document from a text reader.

public static ConventionSnapshot Read(TextReader reader, string? source = null)

Parameters

reader TextReader

The reader.

source string

The source each record reports, or null.

Returns

ConventionSnapshot

Its records.

Exceptions

ArgumentNullException

reader is null.

XmlSchemaValidationException

The document breaks the schema.

Read(string)

Reads a conventions document from a file.

public static ConventionSnapshot Read(string path)

Parameters

path string

The file's path, each record's source.

Returns

ConventionSnapshot

Its records.

Exceptions

ArgumentNullException

path is null.

XmlSchemaValidationException

The document breaks the schema.

XmlException

The file isn't well-formed XML or holds a DTD.

ArgumentException

The document holds no Conventions element, or a record's fields can't make a record.

Read(XElement, string?)

Reads a Conventions element, or the first one an element holds, validating it.

public static ConventionSnapshot Read(XElement element, string? source = null)

Parameters

element XElement

The element.

source string

The source each record reports, or null.

Returns

ConventionSnapshot

Its records.

Exceptions

ArgumentNullException

element is null.

XmlSchemaValidationException

The element breaks the schema.

Read(XmlReader, string?)

Reads a conventions document from an XML reader, validating it as it is read.

public static ConventionSnapshot Read(XmlReader reader, string? source = null)

Parameters

reader XmlReader

The reader, positioned before the document or the element holding the conventions.

source string

The source each record reports, or null.

Returns

ConventionSnapshot

Its records.

Exceptions

ArgumentNullException

reader is null.

XmlSchemaValidationException

The document breaks the schema.

Schema()

The conventions' XML Schema, compiled afresh: a schema set's members aren't safe across threads.

public static XmlSchemaSet Schema()

Returns

XmlSchemaSet

The compiled schema set.

ToXElement(ConventionSnapshot)

A snapshot's Conventions element.

public static XElement ToXElement(ConventionSnapshot snapshot)

Parameters

snapshot ConventionSnapshot

The snapshot.

Returns

XElement

The element, its records in order with the foreign content where it was read.

Exceptions

ArgumentNullException

snapshot is null.

Write(ConventionSnapshot, Stream)

Writes a snapshot as a conventions document in the canonical form.

public static void Write(ConventionSnapshot snapshot, Stream stream)

Parameters

snapshot ConventionSnapshot

The snapshot.

stream Stream

The stream, written UTF-8 without a byte-order mark.

Exceptions

ArgumentNullException

An argument is null.

Write(ConventionSnapshot, TextWriter)

Writes a snapshot as a conventions document in the canonical form, with a final newline.

public static void Write(ConventionSnapshot snapshot, TextWriter writer)

Parameters

snapshot ConventionSnapshot

The snapshot.

writer TextWriter

The writer.

Exceptions

ArgumentNullException

An argument is null.

Write(ConventionSnapshot, XmlWriter)

Writes a snapshot's Conventions element to an XML writer.

public static void Write(ConventionSnapshot snapshot, XmlWriter writer)

Parameters

snapshot ConventionSnapshot

The snapshot.

writer XmlWriter

The writer, which keeps its own settings.

Exceptions

ArgumentNullException

An argument is null.

WriteDefaults(string)

Writes QuantLib's presets, as the library ships them, and the schema into a folder: a full copy of the defaults, to read alone onto Empty.

public static void WriteDefaults(string folder)

Parameters

folder string

The folder, created if needed.

Exceptions

ArgumentNullException

folder is null.