Table of Contents

Method WriteMessage

Namespace
Ploch.CommandLine.Spectre.Output
Assembly
Ploch.CommandLine.Spectre.dll

WriteMessage<TMessage>(TMessage?, IFormatProvider?)

Writes a message of type TMessage using the appropriate writer.

public IMessageWriter? WriteMessage<TMessage>(TMessage? message, IFormatProvider? formatProvider = null)

Parameters

message TMessage

The message to write. If null, no action is taken.

formatProvider IFormatProvider

The format provider to apply, or null to use the current culture.

Returns

IMessageWriter

The registered writer that rendered the message, or null if none could handle it.

Type Parameters

TMessage

The type of the message to write.

Remarks

The writer is selected by the type of message and is then given that same message, together with this processor so it can format the message itself. Handing the writer the already-formatted text instead would defeat the type-based selection: a writer registered for a type a string cannot be cast to — Exception, for example — would fail the cast in Write(object?, IMessageFormatterProcessor?, IFormatProvider?). The caller's format provider travels alongside, so the writer can honour the culture that was asked for.