Table of Contents

Class MarkupValueFormatter

Namespace
Icy.Design
Assembly
IcyUI.Design.dll

Writes property values as markup attribute text that loads back to the same value.

public sealed class MarkupValueFormatter
Inheritance
MarkupValueFormatter
Inherited Members
Extension Methods

Remarks

Each value gets a candidate text in the form people write by hand: invariant-culture numbers, enum names, #AARRGGBB colors, the shortest Thickness form, and comma-separated vector and size components. The candidate is then converted back with the configuration's ITypeConverter, and it's only accepted when that reproduces an equal value. A value with no verified form is refused, so an editor can show it read-only instead of writing markup that wouldn't load.

Constructors

MarkupValueFormatter(ITypeConverter)

Initializes a new instance of the MarkupValueFormatter class.

public MarkupValueFormatter(ITypeConverter converter)

Parameters

converter ITypeConverter

The converter markup loads values with, usually configuration.Types.TypeConverter.

Exceptions

ArgumentNullException

converter is null.

Methods

TryFormat(object?, Type, out string?)

Formats value as markup text for a property of type type.

public bool TryFormat(object? value, Type type, out string? text)

Parameters

value object

The value.

type Type

The property's type.

text string

The markup text, when this method returns true.

Returns

bool

true when a text was found that loads back to an equal value.

Exceptions

ArgumentNullException

type is null.