Table of Contents

Interface IMarkupBuilder

Namespace
Icy.Markup
Assembly
IcyUI.dll

Builds objects from markup fragments, or applies single attributes, exactly as MarkupLoader would while loading a whole document.

public interface IMarkupBuilder
Extension Methods

Remarks

This is the seam design tooling uses to mirror a markup edit onto an already loaded tree, reusing the loader's type resolution, value conversion, markup extensions and name scopes instead of duplicating them. MarkupLoader implements it: IMarkupBuilder builder = new MarkupLoader(configuration);.

Everything built through a MarkupLoadScope is reported to that scope's observer with ObjectCreated(MarkupLoadScope, XElement, object) and MemberApplied(MarkupLoadScope, XObject, object, MarkupMember, object?, IBinding?), as during the original load.

Methods

ApplyAttribute(MarkupLoadScope, object, XAttribute)

Applies one attribute to an already built object, exactly as the loader would.

void ApplyAttribute(MarkupLoadScope scope, object target, XAttribute attribute)

Parameters

scope MarkupLoadScope

The scope of the document target belongs to.

target object

The object to apply the attribute to.

attribute XAttribute

The attribute. It must belong to an element (one from ParseFragment(string, IReadOnlyDictionary<string, string>)), so its namespace and any directive resolve.

Exceptions

MarkupException

The attribute or its value breaks a rule of the language.

ArgumentException

attribute doesn't belong to an element.

InvalidOperationException

The scope's tree has already been collected.

BuildFragment(MarkupLoadScope, XElement, UIElement?)

Builds a fragment's object tree in the context of an observed document.

object BuildFragment(MarkupLoadScope scope, XElement fragment, UIElement? liveParent)

Parameters

scope MarkupLoadScope

The scope of the document the fragment belongs to.

fragment XElement

The fragment, as returned by ParseFragment(string, IReadOnlyDictionary<string, string>).

liveParent UIElement

The live element the result will be added to, or null. {StaticResource} resolves through it and its ancestors, as it would through the elements under construction during a load. The result isn't added to it; that's the caller's job.

Returns

object

The built object. x:Names inside it are registered in the scope's name scope.

Exceptions

MarkupException

The fragment breaks a rule of the language.

InvalidOperationException

The scope's tree has already been collected.

ParseFragment(string, IReadOnlyDictionary<string, string>)

Parses a markup fragment with the same reader settings the loader uses for documents.

XElement ParseFragment(string text, IReadOnlyDictionary<string, string> namespaces)

Parameters

text string

The fragment: exactly one element, with any content.

namespaces IReadOnlyDictionary<string, string>

The namespace declarations the fragment inherits from where it sits in its document, keyed by prefix (the empty string for the default namespace). The x prefix is always predeclared.

Returns

XElement

The fragment's element, with line information relative to text.

Exceptions

MarkupException

The fragment isn't well-formed XML, or uses an undeclared prefix.