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
messageTMessageThe message to write. If null, no action is taken.
formatProviderIFormatProviderThe 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
TMessageThe 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.