Interface IValueObjectFormatter<TValue>
Namespace: AdCodicem.ValueObjects
Assembly: AdCodicem.ValueObjects.Abstractions.dll
Declares that a value object formats itself, rather than deferring to its underlying value.
public interface IValueObjectFormatter<TValue>
Type Parameters
TValue
Underlying value type.
Remarks
Implementing this takes over formatting entirely, including the default format, so it must handle an empty
or null format specifier. It is what gives a value object named formats: an IBAN printed
in groups of four, or masked down to its last four characters. A type that also implements
The generated ToString(format, provider) calls it with a stack buffer, then with a pooled buffer twice as
large each time it returns false, up to 1,048,576 characters, past which it throws a
Methods
TryFormatValue(in TValue, Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Writes the formatted value into a destination buffer.
public static abstract bool TryFormatValue(in TValue value, Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
value TValue
Value to format.
Buffer to write into.
charsWritten int
Characters written, when the buffer was large enough.
format ReadOnlySpan<char>
Format specifier, possibly empty.
provider IFormatProvider?
Format provider.
Returns
false when the destination was too small, as the framework expects.