Table of Contents

Method CanRead

Namespace
DocWright.Formats.Text
Assembly
DocWright.Formats.Text.dll

CanRead(Stream)

Always returns false: plain text is never auto-detected.

public bool CanRead(Stream stream)

Parameters

stream Stream

The seekable stream, examined only to validate the argument.

Returns

bool

false, always.

Remarks

This is a deliberate refusal, not an omission, and it is the one place this package departs from the phase's exit criteria — so it is stated here rather than left to be discovered.

Every byte sequence is valid plain text. A sniff that returned true for anything decodable would claim every stream no other reader recognized: a truncated DOCX, a corrupt .doc, a PNG someone renamed. The caller would get a document full of mojibake instead of the InvalidDocumentException that tells them what actually happened, and no amount of heuristic tuning fixes that, because the heuristic would be deciding a question the bytes do not answer.

Plain text is therefore reached explicitly: by the .txt or .text extension, which the registry resolves without consulting this method, or by passing FormatDetection.Text. Both are tested.

Exceptions

ArgumentNullException

stream is null.

ArgumentException

The stream is not seekable.