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
converterITypeConverterThe converter markup loads values with, usually
configuration.Types.TypeConverter.
Exceptions
- ArgumentNullException
converteris 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
valueobjectThe value.
typeTypeThe property's type.
textstringThe markup text, when this method returns true.
Returns
Exceptions
- ArgumentNullException
typeis null.