Documentation
Table of Contents

Method TryParse

Namespace
IntentSharp.Documents
Assembly
IntentSharp.dll

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.

public bool TryParse(DocumentId id, string text, out ParsedDocument? document, out DocumentProblem? problem)

Parameters

id DocumentId

The document, whose extension chooses the format.

text string

The document's text.

document ParsedDocument

The parsed document; null when parsing failed.

problem DocumentProblem

The load problem; null when parsing succeeded.

Returns

bool

True when the text parsed.

Exceptions

ArgumentNullException

text is null.

ArgumentException

A default DocumentId, which names no document.

OperationCanceledException

The format was canceled while it read the document.