Documentation
Table of Contents

Class DocumentFormats

Namespace
IntentSharp.Documents
Assembly
IntentSharp.dll

The formats documents are read in, chosen by a document's extension. JSON is always registered; the IntentSharp.Catalog and IntentSharp.Guardrails packages add YAML, and AddDocumentFormat(IDocumentFormat) adds any other. Safe to read from several threads, also while a format is added.

public sealed class DocumentFormats
Inheritance
object
DocumentFormats
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Constructors

DocumentFormats()

Creates a registry that holds the JSON format.

Properties

Names

The names of the registered formats, in the order they were added; "json" first.

Methods

Add(IDocumentFormat)

Registers a format for its extensions. A format whose name is already registered (compared ignoring case) is ignored, so two packages may both add "yaml".

TryGet(DocumentId, out IDocumentFormat?)

Finds the format registered for id's extension.

TryParse(DocumentId, string, out ParsedDocument?, out DocumentProblem?)

Parses a document's text with the format registered for its extension. When no format is registered for the extension, the text is not valid in the format, or the format fails to read it, returns false with the load problem: the missing format's problem names the extension and the registered formats; the format's problem (a DocumentFormatException) carries its line when known; any other exception the format throws, other than an OperationCanceledException, becomes a problem naming the format and the exception.