Skip to main content
Version: 0.2.x (0.2.1)

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.

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.

destination Span<char>

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​

bool

false when the destination was too small, as the framework expects.