Table of Contents

Class MarkupConfiguration

Namespace
Icy.Markup
Assembly
IcyUI.dll

The markup facet of ReflectionConfiguration: what the loader may construct, under what names, and how bare text becomes objects.

public class MarkupConfiguration
Inheritance
MarkupConfiguration
Inherited Members
Extension Methods

Remarks

Reached as Markup, and configured fluently through ConfigureMarkup(IConfigurationBuilder, Action<MarkupConfiguration>). It lives alongside the assembly resolver, type converter, and property registry because markup resolution is built entirely out of those three.

Properties

Activator

Gets or sets the service that constructs the objects a markup document declares.

public IMarkupActivator Activator { get; set; }

Property Value

IMarkupActivator

Remarks

Replace this to take over construction wholesale - see IMarkupActivator for what that is for.

BuiltInNamespaces

Gets the CLR namespaces searched, in order, for an unprefixed element name.

public IList<string> BuiltInNamespaces { get; }

Property Value

IList<string>

Remarks

Only types in UIElement's own assembly are searched here - this is the built-in control vocabulary, not a general search path. Custom types come in through a clr-namespace XML namespace or through RegisterShortName<T>(string?).

Extensions

Gets the markup extension types markup may write as {Name ...}, keyed by the name written inside the braces.

public IReadOnlyDictionary<string, Type> Extensions { get; }

Property Value

IReadOnlyDictionary<string, Type>

Remarks

Seeded with "Binding" mapping to BindingExtension, "Localize" mapping to LocalizeExtension, "StaticResource" mapping to StaticResourceExtension, and "TemplateBinding" mapping to TemplateBindingExtension.

LoadObserver

Gets or sets the observer notified about what every MarkupLoader using this configuration builds, and from which markup node.

public IMarkupLoadObserver? LoadObserver { get; set; }

Property Value

IMarkupLoadObserver

Remarks

null by default, and then loading does no extra work at all. Design tooling installs an observer here, typically only in development builds; see IMarkupLoadObserver.

This is a single slot. Tooling that installs an observer should refuse to replace one it didn't install.

ShortNames

Gets the custom types that may be written unprefixed, keyed by the name markup writes.

public IReadOnlyDictionary<string, Type> ShortNames { get; }

Property Value

IReadOnlyDictionary<string, Type>

TextAdapters

Gets the adapters consulted, in order, to turn bare element text into a value its content property can hold.

public IList<IMarkupTextAdapter> TextAdapters { get; }

Property Value

IList<IMarkupTextAdapter>

Remarks

Starts with UIElementTextAdapter. Insert ahead of it to take precedence for a type it also claims; append to handle types it doesn't.

Methods

EnumerateUnprefixedNames()

Enumerates every name that can be written unprefixed, for error messages that suggest a near match.

public IEnumerable<string> EnumerateUnprefixedNames()

Returns

IEnumerable<string>

The built-in control names followed by the registered short names.

FindBuiltIn(string)

Finds the built-in control named name.

public Type? FindBuiltIn(string name)

Parameters

name string

The unqualified type name to look up.

Returns

Type

The built-in type, or null when there is none.

RegisterExtension(Type, string?)

Registers type so markup can invoke it as {Name ...}.

public MarkupConfiguration RegisterExtension(Type type, string? name = null)

Parameters

type Type

The extension type to register. Must implement IMarkupExtension.

name string

The name markup writes inside the braces, or null to derive one from the type's name.

Returns

MarkupConfiguration

This configuration, for chaining.

Exceptions

MarkupException

type doesn't implement IMarkupExtension.

RegisterExtension<T>(string?)

Registers T so markup can invoke it as {Name ...}.

public MarkupConfiguration RegisterExtension<T>(string? name = null) where T : IMarkupExtension, new()

Parameters

name string

The name markup writes inside the braces, or null to derive one from the type's name

  • MyExtension becomes My, following the same Binding/BindingExtension convention as the built-in one.

Returns

MarkupConfiguration

This configuration, for chaining.

Type Parameters

T

The extension type to register.

RegisterShortName(Type, string?)

Registers type so markup can write it without a namespace prefix.

public MarkupConfiguration RegisterShortName(Type type, string? name = null)

Parameters

type Type

The type to register.

name string

The name markup writes, or null to use the type's own name.

Returns

MarkupConfiguration

This configuration, for chaining.

Remarks

Shadowing a built-in is rejected here rather than silently allowed, because a document that reads <Button/> should mean the built-in Button wherever it appears. A replacement is still perfectly possible - declare a clr-namespace prefix and write <my:Button/>, where the substitution is visible in the file that depends on it.

Exceptions

MarkupException

name collides with a built-in control, or with a different type already registered under it.

RegisterShortName<T>(string?)

Registers T so markup can write it without a namespace prefix.

public MarkupConfiguration RegisterShortName<T>(string? name = null)

Parameters

name string

The name markup writes, or null to use the type's own name.

Returns

MarkupConfiguration

This configuration, for chaining.

Type Parameters

T

The type to register.

Exceptions

MarkupException

name collides with a built-in control, or with a different type already registered under it.