Table of Contents

Interface IMarkupTextAdapter

Namespace
Icy.Markup
Assembly
IcyUI.dll

Turns the bare text inside an element into a value its content property can actually hold.

public interface IMarkupTextAdapter
Extension Methods

Remarks

Markup lets an element carry text directly:

<Button>Click Me</Button>

Content is a UIElement, not a string, so the text can't simply be converted - something has to decide what element represents it. That's what an adapter does; the built-in UIElementTextAdapter wraps the text in a TextBlock.

Adapters are consulted only when the content property's type is not assignable from string, and only in TextAdapters order, first match winning - so a registration added later can take precedence over the built-in one by being inserted ahead of it.

Methods

Adapt(string, Type)

Produces the value to assign to a content property of targetType for text.

object? Adapt(string text, Type targetType)

Parameters

text string

The element's text, already trimmed.

targetType Type

The type of the content property the text is being written into.

Returns

object

A value assignable to targetType.

CanAdapt(Type)

Determines whether this adapter can produce a value assignable to targetType.

bool CanAdapt(Type targetType)

Parameters

targetType Type

The type of the content property the text is being written into.

Returns

bool

true when Adapt(string, Type) can handle this type.