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
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
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
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
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
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
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
namestringThe unqualified type name to look up.
Returns
RegisterExtension(Type, string?)
Registers type so markup can invoke it as {Name ...}.
public MarkupConfiguration RegisterExtension(Type type, string? name = null)
Parameters
typeTypeThe extension type to register. Must implement IMarkupExtension.
namestringThe name markup writes inside the braces, or null to derive one from the type's name.
Returns
- MarkupConfiguration
This configuration, for chaining.
Exceptions
- MarkupException
typedoesn'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
namestringThe name markup writes inside the braces, or null to derive one from the type's name
MyExtensionbecomesMy, following the sameBinding/BindingExtension convention as the built-in one.
Returns
- MarkupConfiguration
This configuration, for chaining.
Type Parameters
TThe 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
typeTypeThe type to register.
namestringThe 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
namecollides 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
Returns
- MarkupConfiguration
This configuration, for chaining.
Type Parameters
TThe type to register.
Exceptions
- MarkupException
namecollides with a built-in control, or with a different type already registered under it.