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
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
pathsIEnumerable<string>The files' paths.
Returns
- ConventionSnapshot
Their records.
Exceptions
- ArgumentNullException
pathsor 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
Returns
- ConventionSnapshot
Its records.
Exceptions
- ArgumentNullException
streamis 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
readerTextReaderThe reader.
sourcestringThe source each record reports, or null.
Returns
- ConventionSnapshot
Its records.
Exceptions
- ArgumentNullException
readeris null.- XmlSchemaValidationException
The document breaks the schema.
Read(string)
Reads a conventions document from a file.
public static ConventionSnapshot Read(string path)
Parameters
pathstringThe file's path, each record's source.
Returns
- ConventionSnapshot
Its records.
Exceptions
- ArgumentNullException
pathis null.- XmlSchemaValidationException
The document breaks the schema.
- XmlException
The file isn't well-formed XML or holds a DTD.
- ArgumentException
The document holds no
Conventionselement, 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
Returns
- ConventionSnapshot
Its records.
Exceptions
- ArgumentNullException
elementis 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
readerXmlReaderThe reader, positioned before the document or the element holding the conventions.
sourcestringThe source each record reports, or null.
Returns
- ConventionSnapshot
Its records.
Exceptions
- ArgumentNullException
readeris 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
snapshotConventionSnapshotThe snapshot.
Returns
- XElement
The element, its records in order with the foreign content where it was read.
Exceptions
- ArgumentNullException
snapshotis null.
Write(ConventionSnapshot, Stream)
Writes a snapshot as a conventions document in the canonical form.
public static void Write(ConventionSnapshot snapshot, Stream stream)
Parameters
snapshotConventionSnapshotThe snapshot.
streamStreamThe 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
snapshotConventionSnapshotThe snapshot.
writerTextWriterThe 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
snapshotConventionSnapshotThe snapshot.
writerXmlWriterThe 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
folderstringThe folder, created if needed.
Exceptions
- ArgumentNullException
folderis null.